回答

收藏

求助一个节目抓取问题

问答交流 问答交流 176 人阅读 | 0 人回复 | 2022-08-20

本帖最后由 HF5UaiaeeL6xjq 于 2022-8-20 11:44 编辑

https://www.tvmao.com/program/SZCATV-CHC1-w7.html



想抓取下节目自己方便回看.

如上地址,有部分节目信息,按照浏览器步骤,先获取token然后post获取剩余节目ht是tps:/
/www.tvmao.com/servlet/accessToken?p=channelEpg
python主要代码如下:

en?p=channelEpg

s = requests.session()
channelres = s.get(channelurl,headers=headers)
tokenres = s.get('https://www.tvmao.com/servlet/accessToken?p=channelEpg',headers=headers_xhr)
payload = {"tc":tc,"cc":cc,"w":nweek,"token":token}
afres = s.post("https://www.tvmao.com/servlet/channelEpg",headers=headers_xhr2,data=payload)


token,headers,payload信息打印如下:

  1. [1,"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0dm1hbyIsImlhdCI6MTY2MDk2NDE3MiwiZXhwIjoxNjYwOTY0NzcyLCJhdWQiOiJhY3QiLCJzdWIiOiIxYWU5Y2VhYjdiNGZkMmYwNDQwMmNiODFiMzZhNjIyNiJ9.PLU1_9p5vZYhuxqt9JGg5HvHPSR7r-EhNVUm7XMXWqA"]
  2. /program/SZCATV-CHC1
  3. {'Origin': 'https://www.tvmao.com', 'Referer': 'https://www.tvmao.com/program/SZCATV-CHC1-w7.html', 'Content-Length': '249', 'Accept-Language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7', 'Accept-Encoding': 'gzip, deflate, br', 'Sec-Fetch-Site': 'same-origin', 'Host': 'www.tvmao.com', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36', 'DNT': '1', 'Connection': 'keep-alive', 'Cookie': 'loc=320000; xsuid=26f07852-190c-4e39-9ab1-d16fb488cce8; xsuid_time=2022-3-24; tvm_channel_province=JSTV@%E6%B1%9F%E8%8B%8F', 'Sec-Fetch-Mode': 'cors', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache', 'X-Requested-With': 'XMLHttpRequest', 'Content-Type': 'application/x-www-form-urlencoded', 'Sec-Fetch-Dest': 'empty'}
  4. {'cc': 'CHC1', 'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0dm1hbyIsImlhdCI6MTY2MDk2NDE3MiwiZXhwIjoxNjYwOTY0NzcyLCJhdWQiOiJhY3QiLCJzdWIiOiIxYWU5Y2VhYjdiNGZkMmYwNDQwMmNiODFiMzZhNjIyNiJ9.PLU1_9p5vZYhuxqt9JGg5HvHPSR7r-EhNVUm7XMXWqA', 'tc': 'SZCATV', 'w': '7'}
复制代码

比对和浏览器无异,但是获取到的res:
  1. ��[0,"获取失败,请稍后重试"]
复制代码
求助各位,请指点下,谢谢

分享到:
回复

使用道具 举报

23 积分
1 主题