Difference between Python Xpath and Regex, pythonxpathregex
When crawling webpage information, we often need to use Regex or Xpath.
Differences between the two:
RegexItself isText matching toolBecause it needs to be matched multiple times, it appliesShort and centralized information. It can be precisely matched and captured. HoweverLarge Capacity,Scattered contentHTML and other text, the efficiency will become very low.
XpathUnlike Regex, itXML processing toolBecause HTML is a real subset of XML, it also applies to HTML. From this we can see that the application scope of Xpath is much lower than that of Regex. However, when the application scope is small, it is often more targeted. Xpath traverses XML through the tree structure, and the crawling efficiency of webpage information will be much higher.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.