DrissionPage获取浏览器Network数据包

发布时间:2024年01月14日

DrissionPage是什么?

GitHub - g1879/DrissionPage: 基于python的网页自动化工具。既能控制浏览器,也能收发数据包。可兼顾浏览器自动化的便利性和requests的高效率。功能强大,内置无数人性化设计和便捷功能。语法简洁而优雅,代码量少。基于python的网页自动化工具。既能控制浏览器,也能收发数据包。可兼顾浏览器自动化的便利性和requests的高效率。功能强大,内置无数人性化设计和便捷功能。语法简洁而优雅,代码量少。 - GitHub - g1879/DrissionPage: 基于python的网页自动化工具。既能控制浏览器,也能收发数据包。可兼顾浏览器自动化的便利性和requests的高效率。功能强大,内置无数人性化设计和便捷功能。语法简洁而优雅,代码量少。icon-default.png?t=N7T8https://github.com/g1879/DrissionPage

为什么选择DrissionPage而不选用Selenium?https://wtl4it.blog.csdn.net/article/details/135573492?spm=1001.2014.3001.5502icon-default.png?t=N7T8https://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__()

?

文章来源:https://blog.csdn.net/wtl1992/article/details/135579165
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。