タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

lxmlに関するbojovsのブックマーク (2)

  • lxml

    Introduction lxml is a Pythonic binding for the libxml2 and libxslt libraries. It is unique in that it combines the speed and feature completeness of these libraries with the simplicity of a native Python API, mostly compatible but superior to the well-known ElementTree API. See the introduction for more information about background and goals. Some common questions are answered in the FAQ. This pa

  • lxmlでHTMLページタイトル取得 - Pyro Memo

    一応動くサンプル。あんまりテストしてないので、取得できないパターンはあるかも。 覚えておきたいのはxpathの設定方法で、どうやら //head/title/text() と書くとたまにうまくタイトルが取得できない場合があるようで、そんな場合でも //title/text() という風に直接タグを呼び出したら取得できた。 import re import urllib2 from lxml import etree def get_title_from_url(url, lxml_tree=None): if lxml_tree is None: lxml_tree = get_parsetree_from_url(url) if lxml_tree is None: return None title = None title_block = lxml_tree.xpath("//ti

  • 1