Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://codespeak.net/lxml/index.html#documentation" rel="noreferrer">lxml</a> is faster than BeautifulSoup (I think) and has much better functionality, while remaining relatively easy to use. Example:</p> <pre><code>52&gt; from urllib import urlopen 53&gt; from lxml import etree 54&gt; f = urlopen( "http://www.google.com" ).read() 55&gt; tree = etree.HTML( f ) 61&gt; m = tree.xpath( "//meta" ) 62&gt; for i in m: ..&gt; print etree.tostring( i ) ..&gt; &lt;meta http-equiv="content-type" content="text/html; charset=ISO-8859-2"/&gt; </code></pre> <p>Edit: another example.</p> <pre><code>75&gt; f = urlopen( "http://www.w3schools.com/XPath/xpath_syntax.asp" ).read() 76&gt; tree = etree.HTML( f ) 85&gt; tree.xpath( "//meta[@name='Keywords']" )[0].get("content") 85&gt; "xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,b eginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" </code></pre> <p>BTW: <a href="http://www.w3schools.com/XPath/xpath_syntax.asp" rel="noreferrer">XPath</a> is worth knowing.</p> <p>Another edit:</p> <p>Alternatively, you can just use regexp:</p> <pre><code>87&gt; f = urlopen( "http://www.w3schools.com/XPath/xpath_syntax.asp" ).read() 88&gt; import re 101&gt; re.search( "&lt;meta name=\"Keywords\".*?content=\"([^\"]*)\"", f ).group( 1 ) 101&gt;"xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql, ...etc... </code></pre> <p>...but I find it less readable and more error prone (but involves only standard module and still fits on one line).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload