【发布时间】:2017-08-25 17:32:44
【问题描述】:
我正在尝试使用 Python 下载 SWF 文件, 但由于某种原因,每次我使用 urllib.urlretrieve(url,filepathwithname) 或 wget.download(url) 时,它都会说:
File "C:\Users\User-PC\Desktop\check.py", line 3, in <module>
response =
urllib.urlretrieve('www.domain.com\\folder\\folder\\52sd1399sc2emaple-story-
vthree-f.swf','file.swf')
File "C:\Python27\lib\urllib.py", line 98, in urlretrieve
return opener.retrieve(url, filename, reporthook, data)
File "C:\Python27\lib\urllib.py", line 245, in retrieve
fp = self.open(url, data)
File "C:\Python27\lib\urllib.py", line 213, in open
return getattr(self, name)(url)
File "C:\Python27\lib\urllib.py", line 469, in open_file
return self.open_local_file(url)
File "C:\Python27\lib\urllib.py", line 483, in open_local_file
raise IOError(e.errno, e.strerror, e.filename)
IOError: [Errno 2] The system cannot find the path specified:
'www.domain.com\\folder\\folder\\52sd1399sc2emaple-story-vthree-f.swf'
虽然 wget 行在与我的代码不同的文件中运行该行时仍然给出相同的错误(没有该下载行可以完美运行),但它有时确实有效,但 wget 从不与我放置的 swf 链接一起使用.
*注意。我输入的字符串是“www.domain.com\folder\folder\52sd1399sc2emaple-story-vthree-f.swf”,错误包含“www.domain.com\folder\folder\52sd1399sc2emaple-story-vthree-f.swf ”。
请帮忙。
【问题讨论】:
-
尝试将反斜杠改为正斜杠。
-
@lancew 去过那里,试过了,还是不行 :( 感谢评论!
-
您能出示一下代码吗?
-
请向我们展示您的代码。所以我们可以看到它。
-
您的网络浏览器可能会为您填写 URL 的
http://部分,但urllib不会。在这种情况下,URL 的协议部分不是可选的(使用正确的斜线也不是可选的)。 Stack Overflow 不允许我在评论中写出你的完整 URL(它说使用example.com作为域),但你可以通过自己添加http://来修复它。
标签: python python-2.7 selenium-webdriver python-requests urllib