How to write the Python thesis download script
This article mainly introduces "how to write Python paper download script". In daily operation, I believe many people have doubts about how to write Python paper download script. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to write Python paper download script". Next, please follow the editor to study!
Import urllib
Import re
Import os
Import urlparse
Def auto_down (url, filename):
Try:
Image = urllib.urlretrieve (url, filename)
Except urllib.ContentTooShortError:
Image = auto_down (url, filename)
Return image
Def down_load_cvpr ():
Urls = "http://openaccess.thecvf.com/CVPR2017.py"
Try:
Page = urllib.urlopen (urls)
Html = page.read ()
Reg = ritual hrefs = "(. +?\ .pdf)"'
Imgre = re.compile (reg)
Pdf_list = re.findall (imgre, html)
For pdf in pdf_list:
Target_path = ". / CVPR_2017_paper"
Pdf_url = "http://openaccess.thecvf.com/" + str (pdf)
Url_parse = urlparse.urlparse (pdf_url)
File_name = url_parse.path.split ("/") [- 1]
If not os.path.exists (target_path):
Os.makedirs (target_path)
Target = os.path.join (target_path,'{}'.
Format (file_name))
Print "[*] Downloading paper: {}" .format (pdf_url)
Auto_down (pdf_url, target)
Except:
Pass
If _ name__ = = "_ _ main__":
Down_load_cvpr ()
At this point, the study on "how to write the Python paper download script" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!