>>>urllib.parse.unquote("V%C2%B7EG%208%ED%99%94%20%282%29")
V·EG 8화 (2)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from urllib.request import urlopen import cgi import urllib def fileBaseName(filelink): req = urlopen(filelink) print(req.info()) filenames = req.info()['Content-Disposition'] if filenames is not None: value, params = cgi.parse_header(req.info()['Content-Disposition']) if "filename*" in params: return urllib.parse.unquote(params["filename*"].split("\'\'")[1]) elif "filename" in params: return params["filename"] else: return url.split("/")[-1] print(fileBaseName("http://janggom.tistory.com/attachment/cfile27.uf@995C8A335A98A1BF227BB0.smi")) | cs |
하느(네이버) 게시물 긁었는데 일단 작동하긴 한다
'python' 카테고리의 다른 글
Mutiprocess Downloader (0) | 2018.03.05 |
---|---|
Multiprocessing (0) | 2018.03.04 |
file download (0) | 2018.03.01 |
Blogspot 블로그 RSS (0) | 2018.02.28 |
네이버 블로그 RSS (0) | 2018.02.28 |