This is what I was using to download a pdf from a website. When I don't combine cd.... && part, the curl launches and downloads the file. But, whenever I use the cd command to change the directory and download the file, it just passes the curl command. I don't want to provide -o argument to curl, since I'm not willing to provide custom name to file. Please, suggest the cause of this problem and solution.
The question is unique in the sense that it asks for implementation of curl with bash command. The suggested thread is regarding bash command only.
import subprocess
import shlex
url = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
sessionID = input('Please, enter jsessionid...\n')
sessionID = str(sessionID) # Cookies
cookies_from_function = " -H 'Cookie: rppValue=20; B_View=1; JSESSIONID=" + sessionID + "'"
tempstring = '-L -O -C - ' + url + " -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0) Gecko/20100101 Firefox/64.0' -H 'Accept: */*' --compressed -H 'Connection: keep-alive'" + cookies_from_function# Login To Browser, inspect element, go to network tab, reload, copy curl url for a pdf link. Extract headers with cookies and paste here.
# print(tempstring)
curl_cmd = "cd /Volumes/path/to/destination/ && curl " + tempstring# Original
subprocess.call(shlex.split(curl_cmd))