
上QQ阅读APP看书,第一时间看更新
Getting ready
The code for these snippets is in 02/03_lxml_and_xpath.py in case you want to save some typing. We will start by importing html from lxml, as well as requests, and then load the page.
In [1]: from lxml import html
...: import requests
...: page_html = requests.get("http://localhost:8080/planets.html").text
By this point, lxml should be installed as a dependency of other installs. If you get errors, install it with pip install lxml.