How to change tags on a web page using 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-WEIGH开发者_JAVA百科T: 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!
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.
精彩评论