Automate requests to Primer-BLAST
0
0
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)
requests primer python • 3.9k views
ADD COMMENT
0
Entering edit mode

May I ask how you solve this?

ADD REPLY

Login before adding your answer.

Traffic: 2515 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6