码迷,mamicode.com
首页 > Web开发 > 详细

16.ajax_case06

时间:2019-05-04 00:47:41      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:image   get   json   time   rom   htm   .ajax   实时   content   

# 抓取华尔街见闻实时快讯
# 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

标签:image   get   json   time   rom   htm   .ajax   实时   content   

原文地址:https://www.cnblogs.com/hankleo/p/10807126.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!