Your URL already contains GET parameters:
stitch_results_url = 'http://stitch.embl.de/cgi/show_network_section.pl?identifier=802634%20802659&additional_network_nodes=0&chemicalmode=10.5&input_query_species=7955&interactive=yes&internal_call=1&limit=10&minprotchem=1&network_flavor=actions&required_score=400&sessionId=0ZKGxMnojGDg&targetmode=proteins&userId=Ri1Zp7hT9L9G'
but the form action
attribute does not use these parameters:
<form action="/cgi/show_network_section.pl" id='standard_parameters' method='post'>
Remove these from the URL. Next, don't URL encode everything yourself, leave that to requests
:
import requests
stitch_results_url = 'http://stitch.embl.de/cgi/show_network_section.pl'
# the custom limit of the interaction shown
interaction_shown_custom_limit = 400
# parameters for active prediction methods
neighborhood = 'off'
gene_fusion = 'off'
co_occurrence = 'off'
co_expression = 'off'
experiments = 'on'
databases = 'on'
textmining = 'on'
# required confidence score
required_confidence = 'high confidence (700)'
# Input parameters we are going to send
parameters = {
'channel1': neighborhood,
'channel2': gene_fusion,
'channel3': co_occurrence,
'channel4': co_expression,
'channel5': experiments,
'channel6': databases,
'channel7': textmining,
'required_score':required_confidence,
'custom_limit':interaction_shown_custom_limit
}
req = requests.post(stitch_results_url, params=parameters)
If the form is still not accepted this way, it may be that the JavaScript on that page adds additional information to the form, the form requires the HTTP Referrer header to be set, or the site stores additional information in cookies or a cookie-keyed session.
Use a Session
object to pass along any cookies the site sets, add a Referrer to the request headers, and verify with your browser development tools you didn't miss some POST fields.
I note that you are not including the UserId
and sessionId
parameters, for example. You'll need to include all parameters named in the query portion of the URL for your POST
request to work.