【发布时间】:2019-06-30 18:42:44
【问题描述】:
有一个网页类似于:www.example.com/form.php
我想使用 Python 从页面上的 HTML 表单中获取其中一个值。例如,如果表单有我可以返回值“test”
我已经广泛搜索了这个,但大多数与发布表单数据有关,或者有使用 Django 或 cgi-bin 的建议。我无法直接访问服务器,所以我不能这样做。
我认为库 REQUESTS 可以做到,但我在文档中看不到它。
HTML:
<html>
<body>
<form method="" action="formpost.php" name="form1" id="form1">
<input type="text" name"field1" value="this is field1">
<input type="hidden" name="key" value="secret key field">
</form>
</body>
例如,我希望在 Python 中使用类似的东西:
import special_library
html = special_library.get("http://www.example.com/form.php")
print html.get_field("wanted")
有没有人有任何建议来实现这一目标?或者我可能没有想到或不知道的任何库?
【问题讨论】:
标签: python python-3.x python-requests urllib