- Python Web Scraping Cookbook
- Michael Heydt
- 73字
- 2021-06-30 18:44:01
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.