Skip to main content
Question

Can FME download the css file from a website?

  • March 19, 2019
  • 6 replies
  • 39 views

liujisheng
Participant
Forum|alt.badge.img+2

http://m.dianping.com/shop/22242399

I tired the HTTPcaller to download the .css file from DianPing. It returns an error.

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

lifalin2016
Supporter
Forum|alt.badge.img+38
  • Supporter
  • March 19, 2019

FME should be able to retrieve any resource that can be accessed via HTTP using the HttpCaller. But without the actual url/uri you use to retrieve the CSS, it's rather impossible to comment further. You may also need to set up some specific header information in HttpCaller, e.g. some login or ticket information. In your case maybe also some transfer-encoding information.


liujisheng
Participant
Forum|alt.badge.img+2
  • Author
  • Participant
  • March 19, 2019

FME should be able to retrieve any resource that can be accessed via HTTP using the HttpCaller. But without the actual url/uri you use to retrieve the CSS, it's rather impossible to comment further. You may also need to set up some specific header information in HttpCaller, e.g. some login or ticket information. In your case maybe also some transfer-encoding information.

http://s3plus.meituan.net/v1/mss_0a06a471f9514fc79c981b5466f56b91/svgtextcss/dc63fe513c002f0f6dde345e4bbb7bdf.css

This is the url. I tried to set up the header information in httpcaller, but it doesn't work.


david_r
Celebrity
  • March 19, 2019

Unfortunately the HTTPCaller seems to dislike raw responses without any content-type headers, such as is the case when you try to read the CSS from this server.

However, you can use a small Python script instead:

import fmeobjects
try:
    import urllib2 as urlreq  # Python 2
except:
    import urllib.request as urlreq  # Python 3
    
def raw_get(feature):
    req = urlreq.Request("http://s3plus.meituan.net/v1/mss_0a06a471f9514fc79c981b5466f56b91/svgtextcss/dc63fe513c002f0f6dde345e4bbb7bdf.css")
    contents = urlreq.urlopen(req).read()
    feature.setAttribute('css_contents', contents.decode("utf-8"))

The output feature will have a new attribute css_contents containing the raw text returned by the URL.


liujisheng
Participant
Forum|alt.badge.img+2
  • Author
  • Participant
  • March 19, 2019

Unfortunately the HTTPCaller seems to dislike raw responses without any content-type headers, such as is the case when you try to read the CSS from this server.

However, you can use a small Python script instead:

import fmeobjects
try:
    import urllib2 as urlreq  # Python 2
except:
    import urllib.request as urlreq  # Python 3
    
def raw_get(feature):
    req = urlreq.Request("http://s3plus.meituan.net/v1/mss_0a06a471f9514fc79c981b5466f56b91/svgtextcss/dc63fe513c002f0f6dde345e4bbb7bdf.css")
    contents = urlreq.urlopen(req).read()
    feature.setAttribute('css_contents', contents.decode("utf-8"))

The output feature will have a new attribute css_contents containing the raw text returned by the URL.

Wow! I'll have a try, thanks very much.


jkr_wrk
Influencer
Forum|alt.badge.img+35
  • March 19, 2019

Unfortunately the HTTPCaller seems to dislike raw responses without any content-type headers, such as is the case when you try to read the CSS from this server.

However, you can use a small Python script instead:

import fmeobjects
try:
    import urllib2 as urlreq  # Python 2
except:
    import urllib.request as urlreq  # Python 3
    
def raw_get(feature):
    req = urlreq.Request("http://s3plus.meituan.net/v1/mss_0a06a471f9514fc79c981b5466f56b91/svgtextcss/dc63fe513c002f0f6dde345e4bbb7bdf.css")
    contents = urlreq.urlopen(req).read()
    feature.setAttribute('css_contents', contents.decode("utf-8"))

The output feature will have a new attribute css_contents containing the raw text returned by the URL.

Could we call it a bug that FME is not able to accept raw content. I tried different settings like tread as binary, write to file, but FME does not accept.

I think that if I say the data is binary FME must accept my settings.

 

 


david_r
Celebrity
  • March 19, 2019

Could we call it a bug that FME is not able to accept raw content. I tried different settings like tread as binary, write to file, but FME does not accept.

I think that if I say the data is binary FME must accept my settings.

 

 

Yes, that would be my opinion as well.