Skip to content

Commit a9dad6b

Browse files
committed
Merge pull request #654 from tlevine/master
use .content in lxml
2 parents 184ef03 + 6e4eb1f commit a9dad6b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/scenarios/scrape.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ parse it using the ``html`` module and save the results in ``tree``:
3838
.. code-block:: python
3939
4040
page = requests.get('http://econpy.pythonanywhere.com/ex/001.html')
41-
tree = html.fromstring(page.text)
41+
tree = html.fromstring(page.content)
42+
43+
(We need to use ``page.content`` rather than ``page.text`` because
44+
``html.fromstring`` implicitly expects ``bytes`` as input.)
4245

4346
``tree`` now contains the whole HTML file in a nice tree structure which
4447
we can go over two different ways: XPath and CSSSelect. In this example, we

0 commit comments

Comments
 (0)