📜  python beautifulsoup xpath - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:42.184000             🧑  作者: Mango

代码示例1
try:
    # Python 2
    from urllib2 import urlopen
except ImportError:
    from urllib.request import urlopen
from lxml import etree

url =  "http://www.example.com/servlet/av/ResultTemplate=AVResult.html"
response = urlopen(url)
htmlparser = etree.HTMLParser()
tree = etree.parse(response, htmlparser)
tree.xpath(xpathselector)