iT邦幫忙

0

Html Agility Pack 取網頁資料

https://www.gurufocus.cn/stock/WORK/term/gross_margin
想取上面網站的毛利率
var node = doc.DocumentNode.SelectNodes("//span[@class='text - primary']");
上面是我的寫法,但是是NULL
想請教各位大神我哪裡寫錯?
https://ithelp.ithome.com.tw/upload/images/20200916/20128472M0jt6fzqBH.jpg

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
japhenchen
iT邦超人 1 級 ‧ 2020-09-16 12:13:48
最佳解答

這是透過AJAX動態處理的頁面,毛利率那段並非靜態資料,無法用HTML Agility Package 來抓,但你可以試試用瀏覽器上的F12開發者模式的網路看XHR的內容,把抓JSON/XML/HTML的動作用你的程式直接抓
https://ithelp.ithome.com.tw/upload/images/20200916/20117954fi5H6AoTnQ.jpg

抓這個頁面才對
https://ithelp.ithome.com.tw/upload/images/20200916/20117954DmthPDQyo3.jpg

https://ithelp.ithome.com.tw/upload/images/20200916/20117954ox681bIKok.jpg

qwe891107 iT邦新手 5 級 ‧ 2020-09-16 12:33:22 檢舉

了解 謝謝大哥

我要發表回答

立即登入回答