python - How to retrieve onclick text? -


in webpage have these elements:

<a href="#" onclick="window.open('/link.php?webpage=45980a6f91ac0c850745e0500d612172" class="pagelink" >page 1</a> <a href="#" onclick="window.open('/link.php?webpage=45980a6f91ac0c850745e05676787895" class="pagelink" >page 2</a> <a href="#" onclick="window.open('/link.php?webpage=45980a6f91ac0c85786787666456fgg3" class="pagelink" >page 3</a> <a href="#" onclick="window.open('/link.php?webpage=45980a6f91ac0c850734234324756767" class="pagelink" >page 4</a> ... 

.

and need retrieve text in window.open function of tags of class "pagelink":

/link.php?webpage=45980a6f91ac0c850745e0500d612172 /link.php?webpage=45980a6f91ac0c850745e05676787895 /link.php?webpage=45980a6f91ac0c85786787666456fgg3 /link.php?webpage=45980a6f91ac0c850734234324756767 

how can python ?

from html.parser import htmlparser  class myhtmlparser(htmlparser):      def handle_starttag(self, tag, attrs):         attr = dict(attrs)         if attrs["class"] == "pagelink":             add_to_result(attrs["onclick"]) 

replace add_to_result aggregation object (e.g. list) , actual code, , remove leading window.open results.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -