本文主要是介绍DrissionPage获取浏览器Network数据包,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
DrissionPage是什么?
GitHub - g1879/DrissionPage: 基于python的网页自动化工具。既能控制浏览器,也能收发数据包。可兼顾浏览器自动化的便利性和requests的高效率。功能强大,内置无数人性化设计和便捷功能。语法简洁而优雅,代码量少。基于python的网页自动化工具。既能控制浏览器,也能收发数据包。可兼顾浏览器自动化的便利性和requests的高效率。功能强大,内置无数人性化设计和便捷功能。语法简洁而优雅,代码量少。 - GitHub - g1879/DrissionPage: 基于python的网页自动化工具。既能控制浏览器,也能收发数据包。可兼顾浏览器自动化的便利性和requests的高效率。功能强大,内置无数人性化设计和便捷功能。语法简洁而优雅,代码量少。https://github.com/g1879/DrissionPage
为什么选择DrissionPage而不选用Selenium?https://wtl4it.blog.csdn.net/article/details/135573492?spm=1001.2014.3001.5502https://wtl4it.blog.csdn.net/article/details/135573492?spm=1001.2014.3001.5502 原理:
我们一般是要拿url和response部分 :
代码部分:
drission_page_init:
[paths]
download_path =
tmp_path =[chromium_options]
address = 127.0.0.1:9222
browser_path = C:\Users\10501\AppData\Local\Google\Chrome\Application\chrome.exe
arguments = ['--no-default-browser-check', '--disable-suggestions-ui', '--no-first-run', '--disable-infobars', '--disable-popup-blocking']
extensions = []
prefs = {'profile.default_content_settings.popups': 0, 'profile.default_content_setting_values': {'notifications': 2}}
flags = {}
load_mode = normal
user = Default
auto_port = False
system_user_path = False
existing_only = False[session_options]
headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'connection': 'keep-alive', 'accept-charset': 'GB2312,utf-8;q=0.7,*;q=0.7'}[timeouts]
base = 10
page_load = 30
script = 30[proxies]
http =
https =[others]
retry_times = 3
retry_interval = 2
drissionpage_use.py:
# ---encoding:utf-8---
# @Time : 2024/1/14 07:09
# @Author : stzz Wang
# @Email :1050100468@qq.com
# @Site :
# @File : drissionpage_use.py
# @Project : PythonUtils
# @Software: PyCharm
from DrissionPage import ChromiumOptions , SessionOptions , WebPage
def drissionpage_use():co = ChromiumOptions(ini_path="./config/drission_page_init")so = SessionOptions(ini_path="./config/drission_page_init")page = WebPage(chromium_options=co,session_or_options=so)page.listen.start()page.get("https://baidu.com")for _ in range(50):response = page.listen.wait()print(response.url)def __run_drissionpage_use__():drissionpage_use()if __name__ == '__main__':__run_drissionpage_use__()
这篇关于DrissionPage获取浏览器Network数据包的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!