Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

scrap-render

這個專案提供一個簡單的 Playwright 指令稿,先「渲染」網頁再儲存結果,適合用來抓取需要前端運算才會出現內容的網站。預設目標是 104 人力銀行的公司頁面 https://www.104.com.tw/company/1xzkino,也可以透過命令列參數指定其他網址。

先備需求

  • Python 3.10+
  • 安裝依賴:
    pip install -r requirements.txt
    playwright install chromium
    若執行時仍遇到 Executable doesn't exist at ...chromium_headless_shell... 的錯誤, 指令稿會嘗試自動下載瀏覽器,但也可以手動執行 playwright install --with-deps chromium 再重試。

使用方式

將頁面渲染後的 HTML 儲存到 output/company.html

python scrape_render.py

指定網址與輸出路徑,並同時截圖:

 python scrape_render.py "https://www.104.com.tw/company/1xzkino" --output output/company.html --screenshot output/company.png

產出的 HTML 可用瀏覽器開啟檢查內容,若需要後續再以 BeautifulSoup 等工具解析,也能直接讀取產出的檔案。

Render 部署起始指令

在 Render 上啟動 Worker 時,可將 Start Command 設為:

python scrape_render.py

建議在 Build Command 中加入 Playwright 瀏覽器安裝,以確保執行時可使用 Chromium:

pip install -r requirements.txt && playwright install --with-deps chromium

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages