带有时间参数的Ajax请求不起作用

带有时间参数的Ajax请求不起作用,ajax,Ajax,我试图在Python3中复制我在更改EPG网格中的数据时隙时在Chrome工具的address中看到的ajax请求 这是我的代码: import sys import os import re import requests session = requests.Session() url_list = ['http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?su

我试图在Python3中复制我在更改EPG网格中的数据时隙时在Chrome工具的address中看到的ajax请求

这是我的代码:

import sys
import os
import re
import requests
             
session = requests.Session()

                
url_list = ['http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599019200&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5',
'http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599033600&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5',
'http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599048000&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5',
'http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599062400&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5',
'http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599076800&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5',
'http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599004800&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5']



for url in url_list:
    
    headers ={
    'Accept': '*/*',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8',
    'Connection': 'keep-alive',
    'Host': 'tvmds.tvpassport.com',
    'Referer': 'http://www.canada.com/entertainment/television/tv-listings/index.html',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36'
    }
                                         
    r = session.get(url=url, headers=headers)
    status_code = r.status_code
                                        
    data2 = r.content.decode('utf-8', errors='ignore')
    
    session.close()

    chan_data = re.findall(' channel row -->(.*?)<!--', data2, re.S)

    for chan in chan_data:
        
        if "\'tvm_chan_50\'" in chan:
        
            print(url)
            print(chan)
            print('-' * 150)
导入系统 导入操作系统 进口稀土 导入请求 会话=请求。会话() url_list=['http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599019200&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5', 'http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599033600&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5', 'http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599048000&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5', 'http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599062400&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5', 'http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599076800&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5', 'http://tvmds.tvpassport.com/snippet/white_label/php/grid.php?subid=postmedia&lu=36625D&wd=940&ht=445&mode=json&style=wh&st=1599004800&tz=America%2FToronto&lang=en&ctrlpos=top&items=90&numhours=5'] 对于url_列表中的url: 标题={ “接受”:“*/*”, “接受编码”:“gzip,deflate”, ‘接受语言’:‘en GB,en US;q=0.9,en;q=0.8’, “连接”:“保持活动状态”, ‘主持人’:‘tvmds.tvpsport.com’, “Referer”:http://www.canada.com/entertainment/television/tv-listings/index.html', “用户代理”:“Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/83.0.4103.116 Safari/537.36” } r=session.get(url=url,headers=headers) 状态代码=r.状态代码 data2=r.content.decode('utf-8',errors='ignore') session.close()
chan_data=re.findall('通道行-->(*))如果你在python之外获得url,它是否能像预期的那样工作?不……如果我复制并粘贴到Chrome中,我也会遇到同样的问题。我认为问题更多的是我可能指向了错误的API和/或使用了错误的API参数……那么这与python无关。请编辑你的问题。我修改了标题和标记。其余的都是正确的。你不是Python代码中存在任何错误。您应该明确指出,“如果我复制并粘贴到Chrome中,我也会遇到同样的问题。我认为问题更多的是我可能指向了错误的API和/或使用了错误的API参数。”在您的问题中,因为否则人们将浪费时间试图找出Python代码的错误。