如何使用 mechanize 更改网页上的标签
我正在使用 mechanize 与网站交互。网站是一个具有知识、书籍、期刊、报纸等不同渠道的搜索引擎。一些代码是这样的:
<UL>
<LI id=me_0_1 style="DISPLAY: none; FONT-WEIGHT: bold;">
<A style="width:30px;text-decoration:none;">
<FONT color=#000000>**Knowledge**</FONT>
</A>
</LI>
<LI id=me_0 style="DISPLAY: block;height:20px;width:30px;">
<A onClick="change_Tag('me_0','goqw.jsp','');" href="#" style="width:30px;">**Knowledge**</A>
</LI>
<LI id=me_1_1 style="DISPLAY: none; FONT-WEIGHT: bold;">
<A style="width:30px;text-decoration:none;">
<FONT color=#000000>**Book**</FONT>
</A>
</LI>
<LI id=me_1 style="DISPLAY: block;height:20px;width:30px;">
<A onClick="change_Tag('me_1','search','searchFBook');" href="#" style="width:30px;">**Book**</A>
</LI>
<LI id=me_2_1 style="DISPLAY: none; FONT-WEIGHT: bold;">
<A style="width:30px;text-decoration:none;">
<FONT color=#000000>**Journal**</FONT>
</A>
</LI>
<LI id=me_2 style="DISPLAY: block;height:20px;width:30px;">
<A onClick="change_Tag('me_2','searchJour','searchFJour');" href="#" style="width:30px;">**Journal**</A>
</LI>
</UL>
How to switch between those labels in mechanize?非常感谢!
I am using mechanize to interact with a website. The website is a search engine with different channels such as knowledge, book, journal and newspaper. Some of the code like this:
<UL>
<LI id=me_0_1 style="DISPLAY: none; FONT-WEIGHT: bold;">
<A style="width:30px;text-decoration:none;">
<FONT color=#000000>**Knowledge**</FONT>
</A>
</LI>
<LI id=me_0 style="DISPLAY: block;height:20px;width:30px;">
<A onClick="change_Tag('me_0','goqw.jsp','');" href="#" style="width:30px;">**Knowledge**</A>
</LI>
<LI id=me_1_1 style="DISPLAY: none; FONT-WEIGHT: bold;">
<A style="width:30px;text-decoration:none;">
<FONT color=#000000>**Book**</FONT>
</A>
</LI>
<LI id=me_1 style="DISPLAY: block;height:20px;width:30px;">
<A onClick="change_Tag('me_1','search','searchFBook');" href="#" style="width:30px;">**Book**</A>
</LI>
<LI id=me_2_1 style="DISPLAY: none; FONT-WEIGHT: bold;">
<A style="width:30px;text-decoration:none;">
<FONT color=#000000>**Journal**</FONT>
</A>
</LI>
<LI id=me_2 style="DISPLAY: block;height:20px;width:30px;">
<A onClick="change_Tag('me_2','searchJour','searchFJour');" href="#" style="width:30px;">**Journal**</A>
</LI>
</UL>
How to switch between these tags in mechanize? Many thanks!
您需要嗅探
change_Tag
函数内部发生的情况。打开其源代码并查找 AJAX 请求、重定向、script
标记片段。之后,只需使用 Mechanize 发送适当的请求即可。You need to sniff what's happening inside the
change_Tag
function. Open its sources and look for AJAX-requests, redirects,script
tag insections. After that just send the appropriate request using Mechanize.