Created
November 5, 2019 13:44
-
-
Save 27Cobalter/d61031a364cdac96afa1a247c3736d76 to your computer and use it in GitHub Desktop.
ディレクトリのlist.txtにかかれているURLのパラメータをpngのlargeにしてダウンロードするスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install requests | |
import requests | |
import urllib.parse | |
if __name__ == "__main__": | |
with open("list.txt") as f: | |
lines=f.readlines() | |
for i in range(len(lines)): | |
pr=urllib.parse.urlparse(lines[i]) | |
qs=urllib.parse.parse_qs(pr.query) | |
qs['format']='png' | |
qs['name']='large' | |
url=urllib.parse.urlunparse(pr._replace(query=urllib.parse.urlencode(qs))) | |
print(url) | |
response=requests.get(url) | |
image=response.content | |
with open("pic/"+str(i)+".png",'wb') as wf: | |
wf.write(image) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment