本文共 676 字,大约阅读时间需要 2 分钟。
1、独立cookie。(两个打印结果应该不同)
1 2 3 4 5 6 7 8 9 10 | #coding=utf-8 import grequests urls = [ 'http://www.baidu.com/' , 'http://www.zhihu.com/' , ] rs = [grequests.get(url) for url in urls] grequests. map (rs) for ar in rs: print (ar.session.cookies) |
2、共享cookie。(三个打印结果应该相同)
1 2 3 4 5 6 7 8 9 10 11 12 13 | #coding=utf-8 import grequests import requests urls = [ 'http://www.baidu.com/' , 'http://www.zhihu.com/' , ] sn = requests.Session() rs = [grequests.get(url, session = sn) for url in urls] grequests. map (rs) for ar in rs: print (ar.session.cookies) print (sn.cookies) |
相关阅读:
*** walker ***
本文转自walker snapshot博客51CTO博客,原文链接http://blog.51cto.com/walkerqt/1333146如需转载请自行联系原作者
RQSLT