使用mechanicalsoup-Python输入后显示为输入选项

使用mechanicalsoup-Python输入后显示为输入选项,python,beautifulsoup,mechanicalsoup,Python,Beautifulsoup,Mechanicalsoup,我为这种情况寻找解决方案: 我使用mechanicalsoup将数据导入web: import mechanicalsoup from bs4 import BeautifulSoup as bs4 browser = mechanicalsoup.StatefulBrowser() browser.open("http://webinto.com/into/") browser.select_form('form[action=""]') browser["user"] ="user1"

我为这种情况寻找解决方案:

我使用mechanicalsoup将数据导入web:

import mechanicalsoup
from bs4 import BeautifulSoup as bs4

browser = mechanicalsoup.StatefulBrowser()

browser.open("http://webinto.com/into/")

browser.select_form('form[action=""]')
browser["user"] ="user1"
browser["password"] ="password1"

browser.submit_selected()

print(browser.get_current_page())
我看到了一个应用程序列表:

<td width="394px">
<img alt="" height="16" src="authorizator/vineta.item.gif" title="" width="16"/>
<form action="" enctype="application/x-www-form-urlencoded" method="post" name="f0">
<input name="token" type="hidden" value="123456"/>
<input name="sign" type="hidden" value="7890="/>
<input name="system" type="hidden" value="Application_1"/>
<input name="action" type="hidden" value="GO_SYSTEM"/><h1><a href="javascript: document.f0.submit()">Application 1</a></h1>
<div id="desc0"><h2>Application 1</h2></div>
</form>
</td>
<td width="12px"></td>
<td width="394px">
<img alt="" height="16" src="authorizator/vineta.item.gif" title="" width="16"/>
<form action="" enctype="application/x-www-form-urlencoded" method="post" name="f1">
<input name="token" type="hidden" value="123456"/>
<input name="sign" type="hidden" value="7890"/>
<input name="system" type="hidden" value="Application_2"/>
<input name="action" type="hidden" value="GO_SYSTEM"/><h1><a href="javascript: document.f1.submit()">Application 2</a></h1>
<div id="desc1"><h2>Application 2</h2></div>
</form>
</td>

谢谢

browser.get\u current\u page()
返回被视为BeautifulSoup对象的页面,您可以迭代此对象(请参阅BeautifulSoup的文档)以获取所有
标记,并对其内容调用
print
。我尝试了以下操作:print(browser.get\u current\u page().find\u all('h2'),但我需要查看进入的h2 how选项。如果我需要输入h2:1,请按1,然后输入web 1如果我想输入h2:2,请按2,然后输入web 2。
browser.get\u current\u page()
返回被视为BeautifulSoup对象的页面,您可以迭代此对象(参见BeautifulSoup的文档)以获取所有
标记,然后在他们的内容上调用
print
。我尝试这样做:print(browser.get_current_page().find_all('h2')),但我需要查看进入的h2 how选项。如果我需要输入h2:1,请按1并输入web 1如果我要输入h2:2,请按2并输入web 2。
Press the number of the application to enter:
1.- Application 1
2.- Application 2
3.- Application 3