看板 Python 關於我們 聯絡資訊
小弟爬蟲新手 正在用google的geocode做爬蟲練習 以下是部分原始碼 <GeocodeResponse> <status>OK</status> <result> <type>establishment</type> <type>point_of_interest</type> <type>university</type> 已知用bsobj.find("result").find("type")是第一個type 請問要如何用find或是next_sibling去爬第二個和第三個type? ps:試過用next_sibling() dataType = bsobj.find("result").find("type") dataType2 = dataType.next_sibling() return dataType2 系統給我 TypeError: 'NavigableString' object is not callable -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 73.223.41.252 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1531863864.A.D8C.html
weel99699: 你可以試試看用findall看看 07/18 05:47
iftrush: 恩,可以findAll("type")[1]可弄出第二個 07/18 05:51
iftrush: 不過next_sibling的問題要如何解決? 07/18 05:52
chen1i6c04: for迴圈 + findall("type") 07/18 07:41
TitanEric: next_sibling不是method 不用()另外也可以從錯誤訊息 07/18 10:33
TitanEric: 看出來 07/18 10:33