使用Python進行網頁的整頁截圖

以博客來網站為例

會寫這次的程式,最主要是我想知道有關Python的最新書籍有哪些,但是每次開網頁瀏覽,非常麻煩。

使用Selenium進行截圖

from selenium import webdriver
import time
url='https://search.books.com.tw/search/query/cat/1/qsub/001/key/python/sort/5/c/0'
browser = webdriver.Firefox()
browser.set_window_size(1200,4500) #此步驟為關鍵,設定成整個頁面的長度大小
browser.get(url)
browser.save_screenshot('books.png')
browser.close()

可嘗試的項目:

Written by

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store