PythonRequest在尝试请求网站数据时接收指针错误

2024-10-01 07:33:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在使用Python 3.7.6,在Jupyter笔记本中运行代码,并尝试使用库“request”检索网站数据,但收到一个指针错误-

代码:

from bs4 import BeautifulSoup
import requests

source = requests.get('http://bvmf.bmfbovespa.com.br/indices/ResumoCarteiraTeorica.aspx?Indice=IBOV&idioma=pt-br').text

错误:

OSError: [WinError 10014] - The system detected an invalid pointer address in attempting to use a pointer argument in a call

[...]

NewConnectionError: <urllib3.connection.HTTPConnection object at 0x00000179055507C8>: Failed to establish a new connection: [WinError 10014] The system detected an invalid pointer address in attempting to use a pointer argument in a call

[...]

MaxRetryError: HTTPConnectionPool(host='bvmf.bmfbovespa.com.br.x.ecf9251d0725104833087180eb40dc1a5570.9270ee5e.id.opendns.com', port=80): Max retries exceeded with url: /h/bvmf.bmfbovespa.com.br/indices/ResumoCarteiraTeorica.aspx?X-OpenDNS-Session=_ecf9251d0725104833087180eb40dc1a55709270ee5e_JPweB49M_Indice=IBOV&idioma=pt-br (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000179055507C8>: Failed to establish a new connection: [WinError 10014] The system detected an invalid pointer address in attempting to use a pointer argument in a call'))

[...]

ConnectionError: HTTPConnectionPool(host='bvmf.bmfbovespa.com.br.x.ecf9251d0725104833087180eb40dc1a5570.9270ee5e.id.opendns.com', port=80): Max retries exceeded with url: /h/bvmf.bmfbovespa.com.br/indices/ResumoCarteiraTeorica.aspx?X-OpenDNS-Session=_ecf9251d0725104833087180eb40dc1a55709270ee5e_JPweB49M_Indice=IBOV&idioma=pt-br (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000179055507C8>: Failed to establish a new connection: [WinError 10014] The system detected an invalid pointer address in attempting to use a pointer argument in a call'))

注意:当我尝试在我的个人电脑上运行完全相同的代码时,它可以工作,但是当我尝试在我的工作上运行时,它不能工作


Tags: thetoinbrcomanaddressconnection
1条回答
网友
1楼 · 发布于 2024-10-01 07:33:59

这实际上是一个代理问题。 在以下代码更改后,我可以访问网站的内容-

proxies = {
    "http": "http://myproxy:myport"
}

source = requests.get('http://bvmf.bmfbovespa.com.br/indices/ResumoCarteiraTeorica.aspx?Indice=IBOV&idioma=pt-br', proxies=proxies).text
soup = BeautifulSoup(source, 'html.parser')

相关问题 更多 >