描述问题
http://lxml.de/tutorial.html
我以为有两个构造方法,XML,HTML,然后只要使用这两个对象,就能轻松封装所有操作(lxml话题下提了几个问题), 比如
tree = XML(text) XML(xml_file)
tree = HTML(text) HTML(html_file)
实际上确实能如上面那样,但是该教程, 提供了许多无关内容(当然也许有别的考虑)
使用XPath语法时, 有时候不能得到我的理想结果
但是感觉晦涩
上下文环境
pip show lxml
---
Metadata-Version: 1.1
Name: lxml
Version: 3.5.0
Summary: Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.
Home-page: http://lxml.de/
Author: lxml dev team
Author-email: lxml-dev@lxml.de
License: UNKNOWN
Location: /usr/lib/python2.7/dist-packages
Requires:
Classifiers:
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Intended Audience :: Information Technology
License :: OSI Approved :: BSD License
Programming Language :: Cython
Programming Language :: Python :: 2
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.2
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: C
Operating System :: OS Independent
Topic :: Text Processing :: Markup :: HTML
Topic :: Text Processing :: Markup :: XML
Topic :: Software Development :: Libraries :: Python Modules