No schema supplied and other errors with using requests.get()

后端 未结 5 1110
情深已故
情深已故 2020-12-09 10:05

I\'m learning Python by following Automate the Boring Stuff. This program is supposed to go to http://xkcd.com/ and download all the images for offline viewing.

I\'

5条回答
  •  自闭症患者
    2020-12-09 10:28

    change your comicUrl to this

    comicUrl = comicElem[0].get('src').strip("http://")
    comicUrl="http://"+comicUrl
    if 'xkcd' not in comicUrl:
        comicUrl=comicUrl[:7]+'xkcd.com/'+comicUrl[7:]
    
    print "comic url",comicUrl
    

提交回复
热议问题