在python中使用urllib2将输入值发送到网页

时间:2016-04-14 16:12:49

标签: python html urllib2

我试图获得两组GO术语之间的相似性得分,有一个webpage可以做到这一点,我试图使用python脚本自动化这几个集合的计算。 从我的脚本到目前为止,我生成两个文件,如果手动上传到网页,但我无法弄清楚如何从代码中做到这一点。

temp1 = somefile
url = "http://bioinformatics.clemson.edu/G-SESAME/tools.php?id=3"
isa = "0.8"
partof = "0.6"
for f_set in features_set_list:
    temp2 = open('temp2.txt', "w")
    for item in f_set:
        print >> temp2, item + '\t'
    temp2.close()

    values = {"tool_id":"3","uploadedfile1": temp1,"uploadedfile2": temp2,"isA": isa,"partOf": partof,"email":"False" ,"emailAddress": "","description": "","submit": "Submit"}
    data = urllib.urlencode(values)
    req = urllib2.Request(url, data)
    response = urllib2.urlopen(req)
    html = response.read()
    root = lxml.html.fromstring(html)
    score = root.cssselect("div.row span b")[0].text
    print score

我的猜测是我的错误在作为输入的值中,但找不到它。任何帮助将不胜感激!

0 个答案:

没有答案