16.ajax_case06
Posted hankleo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了16.ajax_case06相关的知识,希望对你有一定的参考价值。
# 抓取华尔街见闻实时快讯
# https://wallstreetcn.com/live/global?from=navbar
import requests
import json
header = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'}
url = 'https://api-prod.wallstreetcn.com/apiv1/content/lives?channel=global-channel&client=pc&limit=20'
response = requests.get(url,headers=header,timeout=5)
# print(json.loads(response.text))
data = json.loads(response.text)['data']
for item in data['items']:
print(item['content_text'].strip())
以上是关于16.ajax_case06的主要内容,如果未能解决你的问题,请参考以下文章