cuốn sách gpt4 ai đã làm

python - 自动在网站中输入一些文本并获取其源代码的python脚本

In lại Tác giả: Walker 123 更新时间:2023-11-28 22:03:50 25 4
mua khóa gpt4 Nike

我正在使用 Python 进行生物医学命名提取。

现在我必须交叉检查将文本输入到 http://text0.mib.man.ac.uk/software/geniatagger/ 的结果并解析我向其中提交文本后得到的 HTML 文本的源代码。

我希望在我的 GUI 本身中完成同样的事情,即它从我制作的 GUI 输入并将文本提交到该网站并获取源代码,以便进行交叉检查我不必访问每个来自浏览器的时间。

Cảm ơn trước

câu trả lời hay nhất

实际上,这是一个很好的问题!

您要做的第一件事是稍微浏览一下网站的源代码。如果您查看网站的源代码,您会看到这段代码



Please enter a text that you want to analyze.










你看到的是请求被发送到一个.cgi地址,因为我们已经在地址上了

http://text0.mib.man.ac.uk/software/geniatagger/

我们要发送的数据将被发送到与此连接的地址

http://text0.mib.man.ac.uk/software/geniatagger/a.cgi

但是我们要向那里发送什么?我们需要一个数据,数据作为“段落”POST 参数发送,您会看到,由于表单具有值为 POST 的属性方法,并且文本区域的名称是“段落”

我们使用这个 python 代码打开它

nhập 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()

到目前为止我们得到了什么?我们为您的 GUI 程序获得了一个“引擎”。你可以做的是用 python 的 HTMLParser 解析这个内容变量。 (选修的)你提到你想在 GUI 中显示它?您可以使用 GTK 或 Qt 执行此操作并将此功能映射到单个按钮,您必须阅读 tutorial ,为此目的真的很容易。如果您有问题,请评论这篇文章,我可以用 GUI 扩展这个答案

关于python - 自动在网站中输入一些文本并获取其源代码的python脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8280157/

25 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress