mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
ini删除chromedriver_path
This commit is contained in:
parent
a0c5072b12
commit
1b25b44479
@ -297,8 +297,6 @@ class WebPageTab(SessionPage, ChromiumTab):
|
||||
selenium_user_agent = self.run_cdp('Runtime.evaluate', expression='navigator.userAgent;')['result']['value']
|
||||
self.session.headers.update({"User-Agent": selenium_user_agent})
|
||||
|
||||
# set_session_cookies(self.session, self._get_driver_cookies(as_dict=True))
|
||||
# set_session_cookies(self.session, self._get_driver_cookies(all_domains=True))
|
||||
set_session_cookies(self.session, super(SessionPage, self).get_cookies())
|
||||
|
||||
def cookies_to_browser(self):
|
||||
@ -306,8 +304,6 @@ class WebPageTab(SessionPage, ChromiumTab):
|
||||
if not self._has_driver:
|
||||
return
|
||||
|
||||
# set_browser_cookies(self, super().get_cookies(as_dict=True))
|
||||
# set_browser_cookies(self, super().get_cookies(all_domains=True))
|
||||
set_browser_cookies(self, super().get_cookies())
|
||||
|
||||
def get_cookies(self, as_dict=False, all_domains=False, all_info=False):
|
||||
@ -320,24 +316,8 @@ class WebPageTab(SessionPage, ChromiumTab):
|
||||
if self._mode == 's':
|
||||
return super().get_cookies(as_dict, all_domains, all_info)
|
||||
elif self._mode == 'd':
|
||||
# return self._get_driver_cookies(as_dict, all_info)
|
||||
return super(SessionPage, self).get_cookies(as_dict, all_domains, all_info)
|
||||
|
||||
# def _get_driver_cookies(self, as_dict=False, all_info=False):
|
||||
# """获取浏览器cookies
|
||||
# :param as_dict: 是否以dict形式返回,为True时all_info无效
|
||||
# :param all_info: 是否返回所有信息,为False时只返回name、value、domain
|
||||
# :return: cookies信息
|
||||
# """
|
||||
# cookies = self.run_cdp('Network.getCookies')['cookies']
|
||||
# if as_dict:
|
||||
# return {cookie['name']: cookie['value'] for cookie in cookies}
|
||||
# elif all_info:
|
||||
# return cookies
|
||||
# else:
|
||||
# return [{'name': cookie['name'], 'value': cookie['value'], 'domain': cookie['domain']}
|
||||
# for cookie in cookies]
|
||||
|
||||
def _find_elements(self, loc_or_ele, timeout=None, single=True, relative=False, raise_err=None):
|
||||
"""返回页面中符合条件的元素、属性或节点文本,默认返回第一个
|
||||
:param loc_or_ele: 元素的定位信息,可以是元素对象,loc元组,或查询字符串
|
||||
|
@ -124,8 +124,6 @@ class WebPageTab(SessionPage, ChromiumTab):
|
||||
def get_cookies(self, as_dict: bool = False, all_domains: bool = False,
|
||||
all_info: bool = False) -> Union[dict, list]: ...
|
||||
|
||||
# def _get_driver_cookies(self, as_dict: bool = False, all_info: bool = False) -> dict: ...
|
||||
|
||||
# ----------------重写SessionPage的函数-----------------------
|
||||
def post(self,
|
||||
url: str,
|
||||
|
@ -1,5 +1,4 @@
|
||||
[paths]
|
||||
chromedriver_path =
|
||||
download_path =
|
||||
|
||||
[chrome_options]
|
||||
|
@ -350,7 +350,6 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
user_agent = self.run_cdp('Runtime.evaluate', expression='navigator.userAgent;')['result']['value']
|
||||
self.session.headers.update({"User-Agent": user_agent})
|
||||
|
||||
# set_session_cookies(self.session, self._get_driver_cookies())
|
||||
set_session_cookies(self.session, super(SessionPage, self).get_cookies())
|
||||
|
||||
def cookies_to_browser(self):
|
||||
@ -373,7 +372,6 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
return super().get_cookies(as_dict, all_domains, all_info)
|
||||
elif self._mode == 'd':
|
||||
return super(SessionPage, self).get_cookies(as_dict, all_domains, all_info)
|
||||
# return self._get_driver_cookies(as_dict, all_info)
|
||||
|
||||
def get_tab(self, tab_id=None):
|
||||
"""获取一个标签页对象
|
||||
@ -383,21 +381,6 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
tab_id = tab_id or self.tab_id
|
||||
return WebPageTab(self, tab_id)
|
||||
|
||||
# def _get_driver_cookies(self, as_dict=False, all_info=False):
|
||||
# """获取浏览器cookies
|
||||
# :param as_dict: 是否以dict形式返回,为True时all_info无效
|
||||
# :param all_info: 是否返回所有信息
|
||||
# :return: cookies信息
|
||||
# """
|
||||
# cookies = self.run_cdp('Network.getCookies')['cookies']
|
||||
# if as_dict:
|
||||
# return {cookie['name']: cookie['value'] for cookie in cookies}
|
||||
# elif all_info:
|
||||
# return cookies
|
||||
# else:
|
||||
# return [{'name': cookie['name'], 'value': cookie['value'], 'domain': cookie['domain']}
|
||||
# for cookie in cookies]
|
||||
|
||||
def close_driver(self):
|
||||
"""关闭driver及浏览器"""
|
||||
if self._has_driver:
|
||||
|
@ -12,7 +12,7 @@ from .base import BasePage
|
||||
from .chromium_driver import ChromiumDriver
|
||||
from .chromium_element import ChromiumElement
|
||||
from .chromium_frame import ChromiumFrame
|
||||
from .chromium_page import ChromiumPage, ChromiumDownloadSetter, ChromiumPageSetter
|
||||
from .chromium_page import ChromiumPage, ChromiumPageSetter
|
||||
from .chromium_tab import WebPageTab
|
||||
from .configs.chromium_options import ChromiumOptions
|
||||
from .configs.session_options import SessionOptions
|
||||
@ -33,7 +33,6 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
self.address: str = ...
|
||||
self._session_options: Union[SessionOptions, None] = ...
|
||||
self._driver_options: Union[ChromiumOptions, None] = ...
|
||||
self._download_set: WebPageDownloadSetter = ...
|
||||
self._download_path: str = ...
|
||||
self._tab_obj: ChromiumDriver = ...
|
||||
|
||||
@ -84,9 +83,6 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
@property
|
||||
def download_path(self) -> str: ...
|
||||
|
||||
@property
|
||||
def download_set(self) -> WebPageDownloadSetter: ...
|
||||
|
||||
def get(self,
|
||||
url: str,
|
||||
show_errmsg: bool = False,
|
||||
@ -131,8 +127,6 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
|
||||
def get_tab(self, tab_id: str = None) -> WebPageTab: ...
|
||||
|
||||
# def _get_driver_cookies(self, as_dict: bool = False, all_info: bool = False) -> dict: ...
|
||||
|
||||
def close_driver(self) -> None: ...
|
||||
|
||||
def close_session(self) -> None: ...
|
||||
@ -187,21 +181,3 @@ class WebPageSetter(ChromiumPageSetter):
|
||||
def headers(self, headers: dict) -> None: ...
|
||||
|
||||
def cookies(self, cookies) -> None: ...
|
||||
|
||||
|
||||
class WebPageDownloadSetter(ChromiumDownloadSetter):
|
||||
def __init__(self, page: WebPage):
|
||||
self._page: WebPage = ...
|
||||
self._behavior: str = ...
|
||||
self._session: Session = None
|
||||
|
||||
@property
|
||||
def _switched_DownloadKit(self) -> DownloadKit: ...
|
||||
|
||||
def save_path(self, path) -> None: ...
|
||||
|
||||
def by_browser(self) -> None: ...
|
||||
|
||||
def by_DownloadKit(self) -> None: ...
|
||||
|
||||
def _download_by_DownloadKit(self, **kwargs) -> None: ...
|
||||
|
20
README.md
20
README.md
@ -24,7 +24,7 @@ DrissionPage 是一个基于 python 的网页自动化工具。
|
||||
|
||||
python 版本:3.6 及以上
|
||||
|
||||
支持浏览器:Chromium 内核浏览器(如 Chrome 和 Edge)
|
||||
支持浏览器:Chromium 内核浏览器(如 Chrome 和 Edge),electron 应用
|
||||
|
||||
---
|
||||
|
||||
@ -34,11 +34,9 @@ python 版本:3.6 及以上
|
||||
|
||||
---
|
||||
|
||||
# 🔥 新版介绍
|
||||
# 🔥 新版预告
|
||||
|
||||
3.2 版已经发布。对底层逻辑进行了梳理,修复了许多问题,提高了稳定性,也对用户 api 进行了调整。
|
||||
|
||||
详情查看:[新版介绍](https://g1879.gitee.io/drissionpagedocs/new/)
|
||||
查看下一步开发计划:[新版预告](http://g1879.gitee.io/drissionpagedocs/whatsnew/3_3/)
|
||||
|
||||
---
|
||||
|
||||
@ -68,7 +66,7 @@ python 版本:3.6 及以上
|
||||
|
||||
本库采用全自研的内核,内置了 N 多实用功能,对常用功能作了整合和优化,对比 selenium,有以下优点:
|
||||
|
||||
- 无 webdriver 特征,不会被网站识别
|
||||
- 无 webdriver 特征
|
||||
|
||||
- 无需为不同版本的浏览器下载不同的驱动
|
||||
|
||||
@ -110,13 +108,7 @@ python 版本:3.6 及以上
|
||||
|
||||
- 还有很多细节,这里不一一列举,欢迎实际使用中体验:)
|
||||
|
||||
---
|
||||
|
||||
# 🌟 特性演示
|
||||
|
||||
[点击查看](http://g1879.gitee.io/drissionpagedocs/2_features/2_features_demos/2_compare_with_selenium/)
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
# 🛠 使用文档
|
||||
|
||||
@ -126,7 +118,7 @@ python 版本:3.6 及以上
|
||||
|
||||
# 🔖 版本历史
|
||||
|
||||
[点击查看版本历史](http://g1879.gitee.io/drissionpagedocs/10_history/)
|
||||
[点击查看版本历史](http://g1879.gitee.io/drissionpagedocs/history/3.x/)
|
||||
|
||||
---
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user