我想抓取此网站的实时黄金价格,http://goldprice.org/live-gol...
我发现它一直用ajax传送实时数据,可以看到,每次都会生成不同的sessionid,这个sessionid是本地生成的吗,又该怎么获得?有了sessionid后,是否需要post全部的信息?
怪我咯2017-04-18 09:55:58
Looking at the website, it seems that the sessionid is not updated in real time.
You can first get the latest sessionid from the web page, and then ensure the same parameters as the ajax request to obtain the data in real time. Set a time yourself, for example, every hour, your request sessionid parameter is replaced with the latest sessionid currently returned to make the request, and so on.
高洛峰2017-04-18 09:55:58
Requests module, make a request first, and then the second request will bring the session
s = requests.Session()
s.get('http://httpbin.org/cookies/set/sessioncookie/123456789')
r = s.get("http://httpbin.org/cookies")
print(r.text)
# '{"cookies": {"sessioncookie": "123456789"}}'