How to download ms word docx file in python with raw data from http url

后端 未结 1 845
走了就别回头了
走了就别回头了 2021-01-16 03:18

if the following url is hit in browser the docx file will be downloaded i want to automate the download with python.

https://hudoc.echr.coe.int/app/conversion/docx/?

相关标签:
1条回答
  • 2021-01-16 04:01

    i have saved the ms word docx file through this

    import requests
    def save_link(book_link, book_name):
        the_book = requests.get(book_link, stream=True)
        with open(book_name, 'wb') as f:
          for chunk in the_book.iter_content(1024 * 1024 * 2):  # 2 MB chunks
            f.write(chunk)
    
    save_link("https://hudoc.echr.coe.int/app/conversion/docx/?library=ECHR&id=001-176931&filename=CASE%20OF%20NDIDI%20v.%20THE%20UNITED%20KINGDOM.docx&logEvent=False","CASE OF NDIDI v. THE UNITED KINGDOM.docx")
    
    0 讨论(0)
提交回复
热议问题