Downloading a picture via urllib and python

后端 未结 18 1338
离开以前
离开以前 2020-11-22 10:35

So I\'m trying to make a Python script that downloads webcomics and puts them in a folder on my desktop. I\'ve found a few similar programs on here that do something simila

18条回答
  •  醉酒成梦
    2020-11-22 11:09

    If you need proxy support you can do this:

      if needProxy == False:
        returnCode, urlReturnResponse = urllib.urlretrieve( myUrl, fullJpegPathAndName )
      else:
        proxy_support = urllib2.ProxyHandler({"https":myHttpProxyAddress})
        opener = urllib2.build_opener(proxy_support)
        urllib2.install_opener(opener)
        urlReader = urllib2.urlopen( myUrl ).read() 
        with open( fullJpegPathAndName, "w" ) as f:
          f.write( urlReader )
    

提交回复
热议问题