A code of mine is now throwing 500 errors (where it didn't before) at a step where I am required to communicate with the following website: http://metagenomics.iiserb.ac.in/mp3/application.php
I am receiving 500 errors when making GET or POST requests, however it works fine in the browser which tells me there's an error with the HTTP headers. When I replicate the headers I see on Chrome as follows, I still get the errors:
payload = {"program": "metabin", "method": "blast", "filetype": "blastresult", "samplefile": "blast", "bitscore": "-0.2", "binsize": "30", "email": "", "submit": "Submit"}
headers = {"Origin": "http://metagenomics.iiserb.ac.in", "Referer": "http://metagenomics.iiserb.ac.in/mp3/application.php", "Upgrade-Insecure-Requests": "1", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36", "X-DevTools-Emulate-Network-Conditions-Client-Id": "A6A0EFE8F8ECE2562D4EDF2B00589DC1"}
requests.post("http://metagenomics.iiserb.ac.in/mp3/submitjob.php", files=payload, headers=headers)
Am I incorrectly copying the HTTP headers? Or is there another step I am missing?
Thanks, Josh.
payload = {"program": "metabin",
"method": "blast",
"filetype": "blastresult",
"samplefile": "blast",
"bitscore": "-0.2",
"binsize": "30",
"email": "",
"submit": "Submit"}
headers = {"Origin": "http://metagenomics.iiserb.ac.in",
"Referer": "http://metagenomics.iiserb.ac.in/mp3/application.php",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36",
"X-DevTools-Emulate-Network-Conditions-Client-Id": "A6A0EFE8F8ECE2562D4EDF2B00589DC1"}
requests.post("http://metagenomics.iiserb.ac.in/mp3/submitjob.php", data=payload, headers=headers)
But I still don't see the "file", as you don't open it binary, to send a file through request post method to a server you should make something similar (these will be just example params!)
data = {'csrf-token' : '214214cqwt21',
'title' : 'Blue sky'}
files = {'file-data' : open("mypicture.jpg", "rb")}
session.post("http://targeturl.com", data = data, files = files)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.