爬虫:今日头条网页求解

from requests.exceptions import RequestException
import requests

def get_one_page(offset,keyword):
    data = {
            'app_name': 'web_search',
            'offset': offset,
            'format': 'json',
            'keyword': keyword,
            'autoload': 'true',
            'count': 20,
            'en_qc': 1,
            'cur_tab': 1,
            'from': 'search_tab',
            'pd': 'synthesis'
            }
    url = 'https://www.toutiao.com/api/search/content/?' + urlencode(data) 
    return url

def get_page_detail(url):
    try:
        response = requests.get(url)
        response.encoding = 'UTF-8' 
        if response.status_code == 200:
            return response.text
        return None
    except RequestException:
        print('ERROR')
        return None

我用了上面可以返回结果,但显示出来的结果是{"count":10,"return_count":10,"query_id":"6537385837821170952","has_more":1,"request_id":"201912

但真正的结果是{"count":20,"return_count":10,"query_id":"6537385837821170952","has_more":1,"request_id":"201912

有没有人知道是什麽原因呢,留意count 後面的数目字 ?

#Python工程师#
全部评论
不提供cookie可能就会随机返回结果吧
点赞 回复
分享
发布于 2019-12-27 11:20
THX QUCIK REPLY 请求是用AJAX 发送的, 如果正如你说的,那我应该怎样改呢
点赞 回复
分享
发布于 2019-12-27 11:30
淘天集团
校招火热招聘中
官网直投

相关推荐

点赞 1 评论
分享
牛客网
牛客企业服务