网页爬虫 - 爬虫python 如何得到sessionid
大家讲道理
大家讲道理 2017-04-18 09:53:58
0
2
492

我想抓取此网站的实时黄金价格,http://goldprice.org/live-gol...
我发现它一直用ajax传送实时数据,可以看到,每次都会生成不同的sessionid,这个sessionid是本地生成的吗,又该怎么获得?有了sessionid后,是否需要post全部的信息?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
刘奇

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.

小葫芦

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"}}'
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template