Python Forum

Full Version: Python script batch download and batch rename
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,

I have a notepad file with a batch of URLs can somebody tell me how a python script can get the URLs and download them at once, also down of each URL the file name exists so once it is downloaded the file gets automatically rename, and this process must be down for 100 URLs?
http://google.com/file/mp4_0
mp4_100
http://google.com/file/mp4_1
mp4_50

This is the concept please help. thanks Smile
you can use requests.get
Thanks, can you send me a simple because I am very new with Python,

Thanks in advance
(Oct-11-2018, 10:26 AM)jkhaksaar Wrote: [ -> ]Thanks, can you send me a simple because I am very new with Python,
You have to show some effort,we do not write finish solution,but try to help along the way.
Can give you some hint to get started.
Read url from a text file:
import requests

with open('url.txt') as f:
    for url_adress in f:
        print(url_adress.strip())
Output:
http://www.example.com/ http://www.example.com/some-URL/
Download example:
import requests

link = 'some url adress'
file_name = 'a_url.pdf'
with open(file_name, 'wb')as f_out:
    f_out.write(requests.get(link).content)
Rename example in this post