Skip to content

Instantly share code, notes, and snippets.

@mapix
Created September 18, 2013 05:19
Show Gist options
  • Select an option

  • Save mapix/6604860 to your computer and use it in GitHub Desktop.

Select an option

Save mapix/6604860 to your computer and use it in GitHub Desktop.
fing element use lxml.cssselector
import urllib
import lxml.html
from lxml.cssselect import CSSSelector
connection = urllib.urlopen('http://dongxi.douban.com/article/1001347/')
dom = lxml.html.fromstring(connection.read())
selAnchor = CSSSelector('a')
foundElements = selAnchor(dom)
print [e.get('href') for e in foundElements]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment