<form method="POST" action="a.cgi">
<p>
Please enter a text that you want to analyze.
</p>
<p>
<textarea name="paragraph" rows="15" cols="80" wrap="soft">
... some text here ...
### This is a sample. Replace this with your own text.
</textarea>
</p>
<p>
<input type="submit" value="Submit Text" />
<input type="reset" />
</p>
</form>
import urllib
import urllib2
text = """
Further, while specific constitutive binding to the peri-kappa B site is seen in monocytes, stimulation with phorbol esters induces additional, specific binding. Understanding the monocyte-specific function of the peri-kappa B factor may ultimately provide insight into the different role monocytes and T-cells play in HIV pathogenesis.
### This is a sample. Replace this with your own text.
"""
data = {
"paragraph" : text
}
encoded_data = urllib.urlencode(data)
content = urllib2.urlopen("http://text0.mib.man.ac.uk/software/geniatagger/a.cgi",
encoded_data)
print content.readlines()
实际上,这是一个很好的问题!在
首先你要做的是探索一点网站的源代码。 如果你看一下网站的源代码,你会看到这段代码
您看到的是请求被发送到a.cgi地址,因为我们已经在地址上了
^{pr2}$我们要发送的数据将被发送到与此连接的地址
但是我们要送什么去那里? 我们需要一个数据,数据是作为“paragraph”POST参数发送的,您可以看到,由于表单具有值POST的属性方法,而textarea的名称是“paragraph”
我们使用这个python代码打开它
到目前为止我们有什么进展?我们为你的GUI程序提供了一个“引擎”。 您可以使用python的HTMLParser(可选)解析这个内容变量 你提到你想用图形用户界面显示这个? 您可以使用GTK或Qt来实现这一点,并将此功能映射到单个按钮上,您必须读取一个tutorial,这样做非常容易。如果你有问题,请评论这篇文章,我可以用GUI扩展这个答案
相关问题 更多 >
编程相关推荐