python 爬取動態數據


按照: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 操作數據庫


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM