I am trying to master the lxml library for parsing sites. When importing the doctest module ( import lxml.html.usedoctest ), I get an error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.5/site-packages/lxml-3.5.0-py3.5-linux-x86_64.egg/lxml/html/usedoctest.py", line 13, in <module> doctestcompare.temp_install(html=True, del_module=__name__) File "/usr/local/lib/python3.5/site-packages/lxml-3.5.0-py3.5-linux-x86_64.egg/lxml/doctestcompare.py", line 398, in temp_install frame = _find_doctest_frame() File "/usr/local/lib/python3.5/site-packages/lxml-3.5.0-py3.5-linux-x86_64.egg/lxml/doctestcompare.py", line 489, in _find_doctest_frame "Could not find doctest (only use this function *inside* a doctest)") LookupError: Could not find doctest (only use this function *inside* a doctest) Maybe someone faced this problem?
I run this code from the manual on the official website:
from lxml.html import builder as e from lxml.html import usedoctest html = e.HTML( e.HEAD( e.LINK(rel='stylesheet', href='style.css', type='text/css'), e.TITLE('lxml TEst') ), e.BODY( e.H1(e.CLASS('heading'), 'Top news!'), e.DIV('DIV',style='width:100px;height:100px;background:#ccc;') ) ) print(lxml.html.tostring(html))
from lxml import etreework? - gil9redroot = etree.XML("...")orroot = etree.HTML("...")- gil9reddoctest." - jfs