[問題] 爬蟲問題..

看板Python作者 (抽筋)時間13年前 (2012/11/12 10:12), 編輯推噓2(203)
留言5則, 3人參與, 最新討論串1/1
我想抓台南縣觀光旅遊局的資料..網址如下 http://tour.tainan.gov.tw/action.aspx?season=spring 不過我用lxml 分析tag 的結構都不對.. 程式碼如下 from lxml import html import urllib2 file = urllib2.urlopen('http://tour.tainan.gov.tw/action.aspx?season=spring') root = html.parse(file).getroot() #這邊都抓不到table... 不過我用chrome 去抓過document tree, 有抓到超過100個... print root.cssselect('table') 不知道我哪邊有做錯了.. 求救.. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.120.142.214

11/12 11:09, , 1F
file.read() ??
11/12 11:09, 1F

11/12 13:08, , 2F
有先寫到檔案看看嗎~常見就是編碼或是HTML的DOM有問題
11/12 13:08, 2F

11/12 20:27, , 3F
有試過wget下來ˇˇ.. 不過一樣..
11/12 20:27, 3F

11/12 20:28, , 4F
html 的dom應該沒有問題>"<
11/12 20:28, 4F

11/12 20:29, , 5F
抓的到body & html.. 不過資料缺一大塊..
11/12 20:29, 5F
文章代碼(AID): #1Ge5iPnp (Python)
文章代碼(AID): #1Ge5iPnp (Python)