Crawler request json data requires cookie request with parameters. What should be done with token in cookie?

clipboard.png
request different pages, sptoken is constantly changing


if you check the relevant information about cookielib, it should be able to solve your problem.
for example:
cj = cookielib.CookieJar ()
opener = urllib2.build_opener (urllib2.HTTPCookieProcessor (cj))
req_index = urllib2.Request (' https://www.xxx.com')
opener.open(req_index)

)

the next request should be able to bring the cookie returned by the above request
req_ajax = urllib2.Request (' https://www.xxx.com/path/to/a.')
res = opener.open (req_ajax)
data = res.read ()
[probably like this, and I didn't execute it either. Try it]

Menu