2016-08-01から1ヶ月間の記事一覧

Pythonでスクレイピング 基本

imabari.hateblo.jp Beautiful Soup Documentation — Beautiful Soup 4.4.0 documentation ウェブページをHTMLで保存し、サーバーへのアクセス回数を減らす 初回アクセス時にHTMLファイルを保存 from urllib.request import urlopen from bs4 import Beautif…

Scrapy

Scrapy Tutorial — Scrapy 1.3.0 documentation Scrapy 1.2 ドキュメント — Scrapy 1.2.2 ドキュメント data.gunosy.io speakerdeck.com # インストール pip install scrapy conda install -c conda-forge scrapy=1.3.0 # プロジェクト作成 scrapy startproj…

netkeibaのスクレイピング

okwave.jp Python3ならできるんだけどPython2ではCSV保存のところでエラーがでてわからない from urllib.request import urlopen from bs4 import BeautifulSoup import csv base_url = 'http://db.netkeiba.com/?pid=jockey_detail&id=00663&page={0}' data…

YOKOHAMAの8文字1列に並べるとき、次のような並べ方は何通りあるか

detail.chiebukuro.yahoo.co.jp def perm(head, rest): if len(rest) == 0: return [head] else: res = [] # set(集合)型で重複を削除、ソート data = sorted(set(rest)) for i in data: # 配列の複製 restx = rest[:] # 指定データ削除 restx.remove(i) h…

出勤簿の判断推理

detail.chiebukuro.yahoo.co.jp 知恵袋で見つけた判断推理の出勤簿の問題をPythonで解いてみた。(2) - rscの日記 # 同じものを含む順列 def perm(head, rest): if len(rest) == 0: return [head] else: res = [] # set(集合)型で重複を削除、ソート data =…