You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用代理调用pandas.read_html时间歇性出现ValueError("No tables found")问题

Python代理环境下pandas.read_html间歇性报ValueError("No tables found")问题

问题

在Python 3.x环境中,结合代理配置使用pandas的read_html解析多个网页时,会间歇性出现无法解释的ValueError("No tables found")报错。

背景

通过动态更新URL中的{team}参数,循环访问32个同域名网页,代码逻辑如下:

for team in teams:
    http_url = f"http://www.footballguys.com/stats/game-logs-against/teams?team={team}&year={season_year}"

两种实现方式对比

1. 不使用代理

直接调用read_html解析网页:

dataframe_list = pd.read_html(http_url)

结果:始终成功,可完整获取32个页面的DataFrame列表。

2. 使用代理

先通过requests带代理请求网页,再将响应文本转为io.StringIO对象后解析:
代理配置代码:

proxies = {
            "http": "http://{}:{}@{}:{}".format(proxy_user, proxy_pass, proxy_host, proxy_port)
        }

注:proxies字典由proxy_user、proxy_pass、proxy_host、proxy_port拼接而成,传入requests.get的proxies参数。

执行代码:

source = requests.get(http_url, proxies=proxies, verify=False).text
dataframe_list = pd.read_html(io.StringIO(source))

结果:频繁无规律失败,可能在第2次或第29次请求后抛出ValueError("No tables found")。

补充测试细节

连续5次代理方式测试的失败详情:

抛出ValueError前成功请求次数失败响应详情
2MAX_THREADS_REACHED
21代理服务商返回:Request failed. You will not be charged for this request...
13http.client.RemoteDisconnected:...
触发连锁异常:urllib3.exceptions.MaxRetryError:...、requests.exceptions.ProxyError:...

说明:请求疑似被拦截,虽使用住宅代理自定义请求头,但拦截情况不符合预期
14MAX_THREADS_REACHED
全部成功-

补充说明

MAX_THREADS_REACHED响应来源不明,已联系代理服务商确认并非其API返回。程序为单线程,代理允许最多5个并发请求,未超出限制,目前无法定位该报错原因。

内容的提问来源于stack exchange,提问作者DAK

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 17:08:11