1、独立cookie。(两个打印结果应该不同)
#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。(三个打印结果应该相同)
#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 ***