Skip to content

Instantly share code, notes, and snippets.

@seikichi
Last active December 19, 2015 09:09
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 seikichi/5930875 to your computer and use it in GitHub Desktop.
Save seikichi/5930875 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# http://futaba.qs.cjb.net/nijiran/fCatalog_MAY.html のタイトル取得が
# うまく出来んと言われたのでやってみた (なげやり)
# lxml は charset 適当に見つけたら上手いこと decode してくれるので
# response.text じゃなくて response.content を lxml.html.fromstring に
# 渡せばいいよとかそんな話
import lxml.html
import requests
response = requests.get('http://futaba.qs.cjb.net/nijiran/fCatalog_MAY.html')
root = lxml.html.fromstring(response.content)
title = root.xpath('//title/text()')[0]
print(title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment