How can I replace the name of pdf
file which is downloaded with Python Requests?
I want to save it as Manual_name1.pdf
not as Elkinson%20
Instead of
pdf_file = link[0].split('/')[-1]
use the specific column from the csv file:
pdf_file = link[1] # (assuming the file name is in the second column)
If the file name is in the first column, you should use
pdf_file = link[0] # (assuming the file name is in the first column)
# OR
import time # put this in the beginning of your script
pdf_file = '{}-{}.pdf'.format(link[0], int(time.time()))
# file name will look like: "name-1495460691.pdf"
but then you will have to change the reference to the link itself when calling it with requests:
a = requests.get(link[1], stream=True) # (assuming the link is in the second column)