Entering edit mode
7.3 years ago
James Ashmore
★
3.5k
I am trying to automate primer design by sending requests to Primer-BLAST. I am able to send the request, but cannot work out how to retrieve the results page. Once you click on the 'Get Primers' button (which executes primertool.cgi script) on the Primer-BLAST website, it waits for completion and then redirects to the results page. The address of the results page is the same as the address listed in the website variable in my script, except it has a few unique IDs attached to the end (CTG and JobID). The request module in Python is supposed to follow any redirects but it doesn't seem to be working.
#!/usr/bin/env python3
import requests
import time
sequence = 'TCTTCTGAGAAAGTCTGAGGCTCCTTAGTACCTTCTCTAGTATGAACTGTTCAGCCTGCCCGCAAGTTGTAACTACGCAGGCGCCAAGACAGCCAACCAAGGAGGCTGCAGA'
parameters = {'INPUT_SEQUENCE': sequence}
website = 'https://www.ncbi.nlm.nih.gov/tools/primer-blast/primertool.cgi'
with requests.session() as session:
poster = session.post(website, data=parameters)
with session.get(poster.url, stream=True) as getter:
print(getter.text)
May I ask how you solve this?