【发布时间】:2020-03-22 19:07:22
【问题描述】:
Iurl = 'https://i7y3a6q5.stackpathcdn.com/media/14490/क-स-न.jpg?width=350&mode=max&animationprocessmode=first'
The above url might generate an error as not all of the characters in it are in Unicode format. So, here's the converted url:
https://i7y3a6q5.stackpathcdn.com/media/14490/%E0%A4%95-%E0%A4%B8-%E0%A4%A8.jpg?width=350&mode=max&animationprocessmode=first
这是导致错误的 url,它是我可以在浏览器中打开的图像的链接。
img = urllib.request.urlopen(Iurl) # Downloading the image
这是产生 404 错误的语句。 我尝试了针对类似问题提供的解决方案,但没有一个对我有用。 当我打印我的 img 时,我需要这样的东西作为我的输出 ss 包含整个错误堆栈跟踪
【问题讨论】:
-
无法重现/
img = request.urlopen('https://i7y3a6q5.stackpathcdn.com/media/14490/%E0%A4%95-%E0%A4%B8-%E0%A4%A8.jpg?width=350&mode=max&animationprocessmode=first')返回http状态码200即成功 -
如果您尝试打印img的内容,它仍然会打印错误404,我也尝试过这种方法。在这里,您不会在外部收到任何错误,但也不会收到任何内容。它应该返回一个包含该图像的对象。
-
你能把实际的错误贴出来
-
这是我尝试打印 img 变量时得到的结果。
标签: python python-3.x web-scraping urllib