python错误状态行错误
当我试图下载Python2.x上带有urllib.urlretrieve的URL时, 我面对这个错误信息 IOError:(“http协议错误”,0,“状态行错误”,无) 这是我的密码:python错误状态行错误,python,url,selenium-webdriver,automation,phantomjs,Python,Url,Selenium Webdriver,Automation,Phantomjs,当我试图下载Python2.x上带有urllib.urlretrieve的URL时, 我面对这个错误信息 IOError:(“http协议错误”,0,“状态行错误”,无) 这是我的密码: from bs4 import BeautifulSoup import re from selenium import webdriver import urllib driver = webdriver.PhantomJS() driver.get("here is the url info") p
from bs4 import BeautifulSoup
import re
from selenium import webdriver
import urllib
driver = webdriver.PhantomJS()
driver.get("here is the url info")
print(driver.page_source)
contents = driver.page_source
soup = BeautifulSoup(contents, "lxml")
a = soup.find(href = re.compile("xlsx"))
print (a)
b = str(a)
web = "http://www. here I but url" + b[9:76] + b[80:130]
print(web)
urllib.urlretrieve(web)
问题
如果你能发布你得到的全部错误,包括回溯,这将是很有帮助的。其中包含的重要信息通常可以帮助我们回答您的问题。我们还希望有一个问题的最小可运行示例-您是否可以验证将
web
硬编码为适当的值(并删除之前除import urlib
之外的所有代码)会产生相同的结果?我们还需要查看您试图检索的实际URL。@在哪一行出现此错误,是driver.get()?谢谢您查看。我可以通过删除电脑上安装的Python2和Python3并只新安装Python2来解决这个问题。