按照:https://dryscrape.readthedocs.io/en/latest/installation.html
安裝dryscrape
以下是簡單實現
import dryscrape
from bs4 import BeautifulSoup
# 使用dryscrape庫 動態抓取頁面
def get_url_dynamic(url):
dryscrape.start_xvfb()
session_req=dryscrape.Session()
session_req.visit(url) #請求頁面
response=session_req.body() #網頁的文本
soup = BeautifulSoup(response, "html.parser")
for k in soup.find_all('a'):
print(k)
# print(soup.prettify())
return response
get_url_dynamic('https://www.cnblogs.com/sweetsunnyflower/p/11156056.html')
使用 pymysql 操作數據庫
