s = requests.Session()
r_token = s.get('https://www.netflix.com/Login',
allow_redirects=False,
proxies=proxies,
headers={'User-Agent': UserAgent().random},
)
我通过代理向netflix发出了python请求,结果无法,但是如果不使用代理,他可以遵循重定向网址
答案 0 :(得分:0)
您需要设置allow_redirects=True
才能进行重定向:
import logging, requests
logging.basicConfig(level=logging.DEBUG)
#proxies = {'https': '144.217.161.149:8080'}
proxies={}
ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.35 Safari/537.36'
s = requests.Session()
r = s.get('https://www.netflix.com/Login',
allow_redirects=True,
proxies=proxies,
headers={'User-Agent': ua},
)
print (r.status_code, r.reason)
打印:
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): www.netflix.com:443
DEBUG:urllib3.connectionpool:https://www.netflix.com:443 "GET /Login HTTP/1.1" 302 0
DEBUG:urllib3.connectionpool:https://www.netflix.com:443 "GET /de-en/Login HTTP/1.1" 200 None
(200, 'OK')
使用代理时,也会发生相同的行为。
Netflix阻止/限制通过代理/ vpn的访问。