[問題] 請教bs4 一些問題

看板Python作者 (mater)時間7年前 (2017/03/24 13:17), 編輯推噓2(202)
留言4則, 4人參與, 最新討論串1/2 (看更多)
http://i.imgur.com/IbIlco2.png
1.請問單獨打links[0] 可以正確顯示第一個 為什麼打兩個links[0,1]不行顯示兩個 2.下面的 TypeError: list indices must be integers or slices, not tuple 它不是原本就是lists嗎 怎麼變成tuple ---------------------------------- http://i.imgur.com/lkRhUSK.png
3. #links[0].get('href') #'ht//example.com/lacie' #links[0].contents # ['Lacie'] 請問這種取出內容物的方法是怎麼知道的 書上沒寫links[0].get('href')的話 我不會知道它可以這樣用 ----------------------------- 4.我發現有些網站 我放入Beautifulsoup後 例: import requests from bs4 import BeautifulSoup res = requests.get('http://xxx.xxx').text soup = BeautifulSoup(res,"html.parser") print(soup) 印出來的東西,有些tag會顯示不出來,好像是包含在<div>內的 tag都不會顯示 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 49.159.113.68 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1490332669.A.945.html

03/24 13:21, , 1F
第二個不是links[1]嗎
03/24 13:21, 1F

03/24 21:35, , 2F
你先學好基本語法吧
03/24 21:35, 2F

03/24 21:47, , 3F
matlab 或是 numpy 的後遺症XD
03/24 21:47, 3F

03/25 05:00, , 4F
感覺是基本語法還沒學就想直接硬幹爬蟲XD
03/25 05:00, 4F
文章代碼(AID): #1OrAlzb5 (Python)
文章代碼(AID): #1OrAlzb5 (Python)