Skip to content

Instantly share code, notes, and snippets.

@t-abe
Created December 27, 2017 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t-abe/cc7cb450134c6b1b70df0e7a4682d7bb to your computer and use it in GitHub Desktop.
Save t-abe/cc7cb450134c6b1b70df0e7a4682d7bb to your computer and use it in GitHub Desktop.
import urllib.request
import lxml.html as html
target_url = 'https://headlines.yahoo.co.jp/hl?a=20171227-00000094-dal-base'
req = urllib.request.urlopen(target_url)
tree = html.parse(req)
r = tree.xpath('//*[@id="ym_newsarticle"]/div[2]/div[1]/p')
print(r[0].text_content())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment