[英]Python Requests returning 503 response
I am using Requests to parse some data on a server. 我正在使用请求来解析服务器上的某些数据。 However, I keep getting a 503 response.
但是,我一直收到503响应。 The request headers have cookies in them, but my method does not seem to be handling them properly.
请求标头中包含cookie,但是我的方法似乎无法正确处理它们。
I am also a bit confused as to what I should be doing with cookies and when full stop. 对于使用cookie和句号应该做什么,我也有些困惑。 The website is
http://epgservices.sky.com/nevermiss/
and my code is below. 网站是
http://epgservices.sky.com/nevermiss/
,下面是我的代码。
Headers and params look correct when viewed in Google Dev Tools, other than the cookies are missing when I use Requests. 在Google开发工具中查看标题和参数时,它们看起来正确,但当我使用“请求”时,缺少cookie。 Any ideas?
有任何想法吗?
import json
import requests
from urllib3.util import Retry
from requests.adapters import HTTPAdapter
from requests import Session, exceptions
import re
import traceback
from cookielib import LWPCookieJar
class sky_ondemand:
session = requests.Session()
jar = session.cookies
url = 'http://epgservices.sky.com'
movie_path = ''.join(movie_path)
headers = {
'Host': 'epgservices.sky.com',
'Connection': 'keep-alive',
'Accept': 'application/json, text/javascript, */*',
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36',
'Referer': 'http://epgservices.sky.com/never-miss/index.htm',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8'
}
params = {
'queryType': 'movieQuery',
'query': '',
'exactMatch': 'false',
'genre': '',
'startsWith': 'all',
'sortBy': 'requested',
'pageNum': '1',
'pageSize': '10',
'src': 'movieLetterButton'
}
r = session.get(url, params=params, headers=headers, cookies=jar)
data = r.content
print(data)
如果有人感兴趣,请对此进行排序....与Cookie无关... URL应该是“ http://epgservices.sky.com/tvlistings-proxy/NeverMissProxy/neverMissMovieSearchRequest.json吗?”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.