403-ProxyError:网址超过了最大重试次数

时间:2020-07-24 04:16:39

标签: python web-scraping request

我正在尝试抓取一个网站,该网站与下面的代码配合正常,但是今天不再起作用,我尝试更改代理和标头,但仍然无法正常工作。

url = 'https://www.zapimoveis.com.br'
    headers = {'User-Agent': 'Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36'}
    proxy = {"https":'https://45.70.60.66:60061'}
    
session = requests.Session()
retry = Retry(connect=3, backoff_factor=0.5)
adapter = HTTPAdapter(max_retries=retry)
session.mount('http://', adapter)
session.mount('https://', adapter)

response = requests.get(url, headers=headers, proxies = proxy)

我得到以下结果:

ProxyError: HTTPSConnectionPool(host='www.zapimoveis.com.br', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x00000292CF206908>: Failed to establish a new connection: [WinError 10060] Uma tentativa de conexão falhou porque o componente conectado não respondeu\r\ncorretamente após um período de tempo ou a conexão estabelecida falhou\r\nporque o host conectado não respondeu')))

0 个答案:

没有答案