import requests
import urllib
from lxml import etree
import os
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36'
}
session = requests.Session() #创建好了session对象
#第一此使用session捕获且储存cookie,猜测对雪球网的首页发起的请 求可能会产生cookie
main_url = 'http://xueqiu.com/'
session.get(main_url,headers=headers)#捕获且存储cookie
url = 'https://stock.xueqiu.com/v5/stock/realtime/quotec.json?symbol=.DJI,.IXIC,.INX&_=1616593138389'
page_text = session.get(url=url,headers=headers).json()
print(page_text)
爬虫s5(爬取请求的cookie)
最新推荐文章于 2024-08-15 20:09:27 发布