爬取今日头条搜索标题

# 加载模块
import requests
from fake_useragent import UserAgent
import time

class Sousuo():

    def __init__(self, i, p):
        # 设置爬虫参数
        self.url = 'https://www.toutiao.com/api/search/content/'  # 传入url
        self.headers = {
     # 设置headers
            'User-Agent': UserAgent().random,
            'Referer': 'https://www.toutiao.com/',
            'accept': 'application/json, text/javascript',
            'accept-language': 'zh-CN,zh;q=0.9',
            'cookie': '__ac_signature=_02B4Z6wo00f01eUl.PwAAIBAqGsupnhz7pnlJfhAACb.d1; ttcid=1e4123b3a1e94f2db2ad69f240af85f032; tt_webid=6953442907778434597; s_v_web_id=verify_knqvo5o4_9DGE20ms_E53X_4HIo_8FtR_Ur20cvC3lbZt; csrftoken=9ce3aab14dcfa071bf08ca198d50dc02; csrftoken=9ce3aab14dcfa071bf08ca198d50dc02; passport_csrf_token_default=d9f4e28e4ec3d09b754c2dc14cbf05d0; passport_csrf_token=d9f4e28e4ec3d09b754c2dc14cbf05d0; sso_auth_status=8b376a6bb786682cbcfe6df13c685699; sso_auth_status_ss=8b376a6bb786682cbcfe6df13c685699; sso_uid_tt=5221408a98f2d1dfe530e12a015c2486; sso_uid_tt_ss=5221408a98f2d1dfe530e12a015c2486; toutiao_sso_user=795948a7b5dd4708cca187e777e0a2d8; toutiao_sso_user_ss

你可能感兴趣的:(python爬虫,python,爬虫,今日头条,json)