开发者

Python urllib POST response

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜