save url as a file name in python

后端 未结 5 864
暖寄归人
暖寄归人 2021-01-06 07:32

Firstly, I\'m pretty new in python, please leave a comment as well if you consider to down vote

I have a url such as

http://example.com/here/there/         


        
5条回答
  •  南笙
    南笙 (楼主)
    2021-01-06 07:55

    Using urllib.urlretrieve:

        import urllib
    
        testfile = urllib.URLopener()
        testfile.retrieve("http://example.com/here/there/index.html", "/tmp/index.txt")
    

提交回复
热议问题