[問題] beautifulsoup爬蟲問題

看板Python作者 (sun抓奶廷已經gg了怎麼뼺)時間5年前 (2020/01/03 05:51), 編輯推噓4(405)
留言9則, 6人參與, 5年前最新討論串1/1
小弟寫了一段程式碼爬蟲 不過很怪 這個網站有部分爬得出來 (https://histock.tw/stock/mainprofit.aspx?no=00632R&from=20181102&to=20181102) 有部分爬不出來 像是我要找這個網站的'table' https://i.imgur.com/eqSE67i.jpg
寫了以下程式碼確找不到: import requests from bs4 import BeautifulSoup source = requests.get('https://histock.tw/stock/mainprofit.aspx?no=00632R&from =20181102&to=20181102', verify= False)ꀊ soup = BeautifulSoup(source.text, ["lxml-xml"]) table = soup.find('table') print(table) 可是有的tag找的到 我去讀soup用肉眼搜尋 裡面還真的沒有table這個tag 不知道是我用的方法不對還是怎樣 麻煩版上強者幫忙解惑了 謝謝!! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.137.84.179 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1578001896.A.141.html

01/03 10:04, 5年前 , 1F
應該是動態網頁
01/03 10:04, 1F

01/03 12:43, 5年前 , 2F
.aspx網頁應該是動態生成網頁內容
01/03 12:43, 2F

01/03 12:43, 5年前 , 3F
可以試試看用selenium套件去爬內容再套bs4
01/03 12:43, 3F

01/03 15:21, 5年前 , 4F
謝謝兩位我晚上試試感謝
01/03 15:21, 4F

01/04 23:32, 5年前 , 5F
bs4 會有讀不到的問題,我之前也用bs4
01/04 23:32, 5F

01/04 23:33, 5年前 , 6F
後來改用 lxml
01/04 23:33, 6F

01/05 02:53, 5年前 , 7F
lxml速度快的多,用selenium下下下策,看一下封包用requ
01/05 02:53, 7F

01/05 02:53, 5年前 , 8F
ests吧
01/05 02:53, 8F

01/05 08:21, 5年前 , 9F
selenium把瀏覽器視窗及載圖關掉
01/05 08:21, 9F
文章代碼(AID): #1U3cNe51 (Python)
文章代碼(AID): #1U3cNe51 (Python)