use regex to search the page one time to get two types of Information

Peter Otten __peter__ at web.de
Fri Aug 19 03:29:46 EDT 2016


iMath wrote:

> I need to use regex to search two types of Information within a web page,

Did you try specialised tools like BeautifulSoup?

> while it seems  searching the page two times rather than one is much time
> consuming 

It "seems"? Try it and only "fix" it if it proves to be a problem, i. e. if 
the regex searches take a significant part of your scripts runtime.

> , is it possible to search the page one time to get two or more
> types of Information?

> each regex only has one matched result in the web page

If the matches are in fixed order you can start the search for the second 
match at the position after the first one. Or you try to combine both 
patterns into one regex.




More information about the Python-list mailing list