速成課程 X

Python 網頁爬蟲

Thomas Laetsch

Data Scientist, NYU

又是一部砍殺片?

xpath = '/html/body/div[2]'

簡單 XPath

  • 單一斜線 / 表示往下一層。
  • 斜線間的標籤名稱指向要找的元素。
  • 標籤名後的中括號 [] 指定同層中的第幾個。
Python 網頁爬蟲

又是一部砍殺片?

反白的 div

xpath = '/html/body/div[2]'
Python 網頁爬蟲

砍殺片雙重放映?

  • 指向整份 HTML 中所有的 table 元素:
xpath = '//table'
  • 指向 body 元素之第 2 個 div 子層後代中的所有 table 元素:
xpath = '/html/body/div[2]//table`
Python 網頁爬蟲

Ex(path)celent

Python 網頁爬蟲

Preparing Video For Download...