运行python脚本时出现回溯错误

时间:2017-11-13 10:04:39

标签: python-3.x

我正在尝试运行此脚本

import requests
from bs4 import BeautifulSoup

url = 'http://www.showmeboone.com/sheriff/JailResidents/JailResidents.asp'
response = requests.get(url)
html = response.content

soup = BeautifulSoup(html)
table = soup.find('tbody', attrs={'class': 'stripe'})
for row in table.findAll('tr'):
print (row.prettify())

我收到此错误:

Traceback (most recent call last)
File: "C:\Users\s\Appdata\Local\Programs\Python\Python36-32\lib\site-
packages\urllib3\connection.py", line 141, in _new_conn

1 个答案:

答案 0 :(得分:0)

我尝试了你的代码。看看完整的追溯。它说超时错误。您使用的网址没有响应。

同时更改

soup = BeautifulSoup(html)

soup = BeautifulSoup(html, 'html.parser')