开发者

Python urllib POST response

开发者 https://www.devze.com 2023-02-23 12:05 出处:网络
I am trying to write script that searches an inchikey (ex: OBSSCZVQJAGPOE-KMKNQKDISA-N) to get a chemical structure from this website:

I am trying to write script that searches an inchikey (ex: OBSSCZVQJAGPOE-KMKNQKDISA-N) to get a chemical structure from this website: http://www.chemspider.com/inchi-resolver/Resolver.aspx

From the documentation my code looks like it should work, but instead it just returns the original search page.

Thanks for the help,

import urllib

inchi = 'OBSSCZVQJAGPOE-KMKNQKDISA-N'

u开发者_开发百科rl = 'http://www.chemspider.com/inchi-resolver/Resolver.aspx'

data = urllib.urlencode({'"ctl00$ContentPlaceHolder1$TextBox1"':inchi})

response = urllib.urlopen(url, data)

print response.read()


Your code is performing a GET request and not a POST request. Apart from that: the form contains various hidden fields with some strange values which might be necessary for the processing as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消