Downloading a picture via urllib and python

后端 未结 18 1679
离开以前
离开以前 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:06

    A simpler solution may be(python 3):

    import urllib.request
    import os
    os.chdir("D:\\comic") #your path
    i=1;
    s="00000000"
    while i<1000:
        try:
            urllib.request.urlretrieve("http://www.gunnerkrigg.com//comics/"+ s[:8-len(str(i))]+ str(i)+".jpg",str(i)+".jpg")
        except:
            print("not possible" + str(i))
        i+=1;
    

提交回复
热议问题