首页 > 代码库 > python测试抓取今日头条

python测试抓取今日头条

# coding:utf-8
import requests
import json

url = http://www.toutiao.com/search_content/?offset=0&format=json&keyword=%E5%B0%8F%E5%BA%B7%E7%A4%BE%E4%BC%9A&autoload=true&count=20&cur_tab=1
wbdata = requests.get(url).text

data = json.loads(wbdata)
news = data[data]

for n in news:
    if title in n:
      title = n[title]
      source = n[source]
      url = n[article_url]
      keyword = n[keywords]
      print(title,url,keyword,source)

 

1.浏览器中找到内容的接口

技术分享

2.找到需要的内容和url

技术分享

3.返回结果

技术分享

python测试抓取今日头条