雪球网新闻标题的爬取
作者:互联网
import requests
import json
headers = {
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
}
url = 'https://xueqiu.com/statuses/hot/listV2.json?'
params = {'since_id':' -1',
'max_id': '-1',
'size': '15'
}
sess = requests.Session() # 实例化一个Session对象
sess.get(url='https://xueqiu.com/',headers=headers)
data_page = sess.get(url=url,headers=headers,params=params).json()
for data in data_page['items']:
print(data['original_status']['title'])
标签:sess,url,新闻标题,headers,params,球网,data,id 来源: https://www.cnblogs.com/KingOfCattle/p/12930789.html