今日头条爬虫关键参数解析

from selenium import webdriver// 先导入selenium模块,没安装的自行百度安装就好
firefox = webdriver.Firefox()
firefox.get('https://www.toutiao.com/ch/news_fashion/')// 头条链接
ascp = firefox.execute_script('return ascp.getHoney()') // 获取连接中的as与cp的值
sinature = firefox.execute_script('return TAC.sign(' + str(max_behot_time) + ')')// 获取链接中的sinature的值
    def getASCP(max_behot_time=None):
        if max_behot_time:
            c_time = max_behot_time
        else:
            c_time = int(math.floor(time.time()))

        e = hex(c_time).upper()[2:]
        md5 = hashlib.md5()
        md5.update(str(c_time).encode(encoding='utf-8'))
        i = md5.hexdigest().upper()

        if len(e) != 8:
            AS = '479BB4B7254C150'
            CP = '7E0AC8874BB0985'
            return AS, CP
        n = i[0:5]
        a = i[-5:]
        s = ''
        r = ''
        for o in range(5):
            s += n[o] + e[o]
            r += e[o + 3] + a[o]

        AS = 'A1' + s + e[-3:]
        CP = e[0:3] + r + 'E1'
        return AS, CP, c_time

    def get_sinature(c_time):
        self.firefox.get('https://www.toutiao.com/ch/internet/')
        sinature = self.firefox.execute_script('return TAC.sign({})'.format(c_time))
        return sinature

 

转载于:https://www.cnblogs.com/shiluoliming/p/8677374.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值