Trying to receive Data from Website

Hi, I'm trying to receive data from a website using the Http request Node from https://api.cellmapper.net/v6/getSite?MCC=228&MNC=1&Site=00000&RAT=LTE. When accessing the URL on chrome, I can clearly see the data I want to access in a JSON format. When using Inject timestamp -> HTTP request -> debug I don't receive the data... Does anyone have a clue what I am missing?

When I tried it - I got this

Yes I got the same response. However when visiting the URL in the browser the data I want is clearly visible. I tried to get the data using Python and it worked somehow.

###Python3

from urllib.request import urlopen, Request
url = "https://api.cellmapper.net/v6/getSite?MCC=228&MNC=1&Site=00000&RAT=LTE"
request = Request(url)
response = urlopen(request)
html = response.read()
response.close()
print(html)

returns the content of the URL.. I would like to use Node Red instead of Python and I haven't found out how to get the same response...

1 Like

Perhaps you could trick the server by adding a message header with a fake user-agent ? I see that the response from server is gziped. You will need to unzip the reply.

1 Like

Thank you for the input Andrei! I will try to test your idea.

Try this flow, it works (just learned from another topic):

[{"id":"a288ed10.713a5","type":"inject","z":"ab533118.ebed78","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":144,"y":264,"wires":[["726ecebb.3baf88"]]},{"id":"726ecebb.3baf88","type":"function","z":"ab533118.ebed78","name":"","func":"\nurl = `\"https://api.cellmapper.net/v6/getSite?MCC=228&MNC=1&Site=00000&RAT=LTE\" \\\n-XGET \\\n-H 'Cookie: JSESSIONID=node01wwvg93m60l2r1a36c8iewh3mk8349.node0' \\\n-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \\\n-H 'Host: api.cellmapper.net' \\\n-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15' \\\n-H 'Accept-Language: en-us' \\\n-H 'Accept-Encoding: gzip, deflate, br' \\\n-H 'Connection: keep-alive'`\nreturn {payload:url};","outputs":1,"noerr":0,"x":312,"y":264,"wires":[["47a47836.68e428"]]},{"id":"47a47836.68e428","type":"exec","z":"ab533118.ebed78","command":"curl --compressed","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":498,"y":264,"wires":[["19491de3.38a09a"],[],[]]},{"id":"e423b027.553988","type":"debug","z":"ab533118.ebed78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":818,"y":264,"wires":[]},{"id":"19491de3.38a09a","type":"json","z":"ab533118.ebed78","name":"","property":"payload","action":"","pretty":false,"x":674,"y":264,"wires":[["e423b027.553988"]]}]
2 Likes

Thank you very much bakman2! You just solved my problem!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.