- くだすれPython(超初心者用) その28©2ch.net
767 :デフォルトの名無しさん[sage]:2016/01/27(水) 23:25:53.18 ID:/6EU7qrh - >>761
そのサイトは、<diary_snap>および<diary_snap_cut>という、 本来のhtmlにはない独自タグをhtmlソースの中で使っている。 これが何か悪さをしているのではないか。というのも、 以下のようにこのタグを除去してからpandasに渡したら、 すべてのtableを取得することができた。 import re #from urllib import urlopen #if Python2 from urllib.request import urlopen import pandas as pd html = urlopen('http://db.netkeiba.com/race/201544122901/').read().decode('euc-jp') html = re.sub(r'</?diary_snap(_cut)?>', '', html) tables = pd.io.html.read_html(html)
|
|