Skip to main content
Question

Can FME download the css file from a website?


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.

 

6 replies

lifalin2016
Contributor
Forum|alt.badge.img+29
  • Contributor
  • 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
lifalin2016 wrote:

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
david_r wrote:

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+29
  • March 19, 2019
david_r wrote:

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
jkr_da wrote:

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.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings