mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
3.2.35修复问题(详)
tabs属性忽略隐私声明 修复 8x 版浏览器选择下拉列表时报错问题 修复某些情况下下拉框不触发联动的问题 修复配置文件损坏时出现的问题 修复get()方法url含某些特殊字符时连接失败的问题
This commit is contained in:
parent
f991e3dd81
commit
38dcc88dfa
@ -19,3 +19,5 @@ try:
|
||||
from .configs.driver_options import DriverOptions
|
||||
except ModuleNotFoundError:
|
||||
pass
|
||||
|
||||
__version__ = '3.2.35'
|
||||
|
@ -387,7 +387,7 @@ class BasePage(BaseParser):
|
||||
:param interval: 重试间隔
|
||||
:return: 重试次数和间隔组成的tuple
|
||||
"""
|
||||
self._url = quote(url, safe='/:&?=%;#@+![]')
|
||||
self._url = quote(url, safe='-_.~!*\'"();:@&=+$,/\\?#[]%')
|
||||
retry = retry if retry is not None else self.retry_times
|
||||
interval = interval if interval is not None else self.retry_interval
|
||||
return retry, interval
|
||||
|
@ -1815,7 +1815,7 @@ class ChromiumSelect(object):
|
||||
@property
|
||||
def options(self):
|
||||
"""返回所有选项元素组成的列表"""
|
||||
return self._ele.eles('xpath://option')
|
||||
return [e for e in self._ele.eles('xpath://option') if isinstance(e, ChromiumElement)]
|
||||
|
||||
@property
|
||||
def selected_option(self):
|
||||
@ -2020,7 +2020,7 @@ class ChromiumSelect(object):
|
||||
|
||||
def _dispatch_change(self):
|
||||
"""触发修改动作"""
|
||||
self._ele.run_js('this.dispatchEvent(new UIEvent("change"));')
|
||||
self._ele.run_js('this.dispatchEvent(new Event("change", {bubbles: true}));')
|
||||
|
||||
|
||||
class ChromiumElementWaiter(object):
|
||||
|
@ -131,7 +131,8 @@ class ChromiumPage(ChromiumBase):
|
||||
def tabs(self):
|
||||
"""返回所有标签页id组成的列表"""
|
||||
j = self._control_session.get(f'http://{self.address}/json').json() # 不要改用cdp
|
||||
return [i['id'] for i in j if i['type'] == 'page']
|
||||
return [i['id'] for i in j if i['type'] == 'page' and not i['url'].startswith('devtools://') and i[
|
||||
'url'] != 'chrome://privacy-sandbox-dialog/notice']
|
||||
|
||||
@property
|
||||
def main_tab(self):
|
||||
|
@ -3,18 +3,18 @@
|
||||
@Author : g1879
|
||||
@Contact : g1879@qq.com
|
||||
"""
|
||||
from json import load, dump
|
||||
from json import load, dump, JSONDecodeError
|
||||
from pathlib import Path
|
||||
from platform import system
|
||||
from subprocess import Popen, DEVNULL
|
||||
from tempfile import gettempdir
|
||||
from time import perf_counter, sleep
|
||||
from platform import system
|
||||
|
||||
from requests import get as requests_get
|
||||
|
||||
from DrissionPage.configs.chromium_options import ChromiumOptions
|
||||
from DrissionPage.errors import BrowserConnectError
|
||||
from .tools import port_is_using
|
||||
from ..configs.chromium_options import ChromiumOptions
|
||||
from ..errors import BrowserConnectError
|
||||
|
||||
|
||||
def connect_browser(option):
|
||||
@ -43,7 +43,7 @@ def connect_browser(option):
|
||||
|
||||
# 传入的路径找不到,主动在ini文件、注册表、系统变量中找
|
||||
except FileNotFoundError:
|
||||
from DrissionPage.easy_set import get_chrome_path
|
||||
from ..easy_set import get_chrome_path
|
||||
chrome_path = get_chrome_path(show_msg=False)
|
||||
|
||||
if not chrome_path:
|
||||
@ -136,7 +136,10 @@ def set_prefs(opt):
|
||||
f.write('{}')
|
||||
|
||||
with open(prefs_file, "r", encoding='utf-8') as f:
|
||||
prefs_dict = load(f)
|
||||
try:
|
||||
prefs_dict = load(f)
|
||||
except JSONDecodeError:
|
||||
prefs_dict = {}
|
||||
|
||||
for pref in prefs:
|
||||
value = prefs[pref]
|
||||
|
@ -1,7 +1,7 @@
|
||||
from click import command, option
|
||||
|
||||
from DrissionPage import ChromiumPage
|
||||
from DrissionPage.easy_set import set_paths, configs_to_here as ch
|
||||
from ..chromium_page import ChromiumPage
|
||||
from ..easy_set import set_paths, configs_to_here as ch
|
||||
|
||||
|
||||
@command()
|
||||
|
@ -3,7 +3,7 @@
|
||||
@Author : g1879
|
||||
@Contact : g1879@qq.com
|
||||
"""
|
||||
from DrissionPage.errors import ElementNotFoundError
|
||||
from ..errors import ElementNotFoundError
|
||||
|
||||
HANDLE_ALERT_METHOD = 'Page.handleJavaScriptDialog'
|
||||
FRAME_ELEMENT = ('iframe', 'frame')
|
||||
|
@ -6,8 +6,8 @@
|
||||
from pathlib import Path
|
||||
from tempfile import gettempdir, TemporaryDirectory
|
||||
|
||||
from DrissionPage.commons.tools import port_is_using, clean_folder
|
||||
from .options_manage import OptionsManager
|
||||
from ..commons.tools import port_is_using, clean_folder
|
||||
|
||||
|
||||
class ChromiumOptions(object):
|
||||
|
@ -8,8 +8,8 @@ from pathlib import Path
|
||||
from requests import Session
|
||||
from requests.structures import CaseInsensitiveDict
|
||||
|
||||
from DrissionPage.commons.web import cookies_to_tuple, set_session_cookies
|
||||
from .options_manage import OptionsManager
|
||||
from ..commons.web import cookies_to_tuple, set_session_cookies
|
||||
|
||||
|
||||
class SessionOptions(object):
|
||||
|
@ -16,7 +16,7 @@ from .session_page import SessionPage
|
||||
|
||||
try:
|
||||
from selenium import webdriver
|
||||
from DrissionPage.mixpage.drission import Drission
|
||||
from .mixpage.drission import Drission
|
||||
from .configs.driver_options import DriverOptions
|
||||
except ModuleNotFoundError:
|
||||
pass
|
||||
|
@ -7,8 +7,8 @@ from abc import abstractmethod
|
||||
from re import sub
|
||||
from urllib.parse import quote
|
||||
|
||||
from DrissionPage.commons.web import format_html
|
||||
from DrissionPage.commons.locator import get_loc
|
||||
from ..commons.locator import get_loc
|
||||
from ..commons.web import format_html
|
||||
|
||||
|
||||
class BaseParser(object):
|
||||
|
@ -14,11 +14,11 @@ from selenium.webdriver.chrome.options import Options
|
||||
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
|
||||
from tldextract import extract
|
||||
|
||||
from DrissionPage.commons.tools import get_pid_from_port, get_exe_from_port
|
||||
from DrissionPage.commons.browser import connect_browser
|
||||
from DrissionPage.commons.web import cookies_to_tuple
|
||||
from DrissionPage.configs.session_options import SessionOptions, session_options_to_dict
|
||||
from DrissionPage.configs.driver_options import DriverOptions
|
||||
from ..commons.browser import connect_browser
|
||||
from ..commons.tools import get_pid_from_port, get_exe_from_port
|
||||
from ..commons.web import cookies_to_tuple
|
||||
from ..configs.driver_options import DriverOptions
|
||||
from ..configs.session_options import SessionOptions, session_options_to_dict
|
||||
|
||||
|
||||
class Drission(object):
|
||||
@ -399,7 +399,7 @@ def create_driver(chrome_path, driver_path, options):
|
||||
# 若版本不对,获取对应 chromedriver 再试
|
||||
except (WebDriverException, SessionNotCreatedException):
|
||||
print('打开失败,尝试获取driver。\n')
|
||||
from DrissionPage.easy_set import get_match_driver, get_chrome_path
|
||||
from ..easy_set import get_match_driver, get_chrome_path
|
||||
|
||||
if chrome_path == 'chrome':
|
||||
chrome_path = get_chrome_path(show_msg=False, from_ini=False)
|
||||
|
@ -15,10 +15,10 @@ from selenium.webdriver.support import expected_conditions as ec
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
|
||||
from .base import DrissionElement, BaseElement
|
||||
from DrissionPage.commons.locator import str_to_loc, get_loc
|
||||
from DrissionPage.commons.tools import get_usable_path
|
||||
from DrissionPage.commons.web import format_html, get_ele_txt
|
||||
from .session_element import make_session_ele
|
||||
from ..commons.locator import str_to_loc, get_loc
|
||||
from ..commons.tools import get_usable_path
|
||||
from ..commons.web import format_html, get_ele_txt
|
||||
|
||||
|
||||
class DriverElement(DrissionElement):
|
||||
|
@ -13,9 +13,9 @@ from selenium.webdriver.remote.webelement import WebElement
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
|
||||
from .base import BasePage
|
||||
from DrissionPage.commons.tools import get_usable_path
|
||||
from .driver_element import DriverElement, make_driver_ele, Scroll, ElementWaiter
|
||||
from .session_element import make_session_ele
|
||||
from ..commons.tools import get_usable_path
|
||||
|
||||
|
||||
class DriverPage(BasePage):
|
||||
|
@ -10,8 +10,8 @@ from lxml.etree import tostring
|
||||
from lxml.html import HtmlElement, fromstring
|
||||
|
||||
from .base import DrissionElement, BasePage, BaseElement
|
||||
from DrissionPage.commons.locator import get_loc
|
||||
from DrissionPage.commons.web import get_ele_txt, make_absolute_link
|
||||
from ..commons.locator import get_loc
|
||||
from ..commons.web import get_ele_txt, make_absolute_link
|
||||
|
||||
|
||||
class SessionElement(DrissionElement):
|
||||
|
@ -13,9 +13,9 @@ from requests.structures import CaseInsensitiveDict
|
||||
from tldextract import extract
|
||||
|
||||
from .base import BasePage
|
||||
from DrissionPage.configs.session_options import SessionOptions
|
||||
from DrissionPage.commons.web import cookie_to_dict, set_session_cookies
|
||||
from .session_element import SessionElement, make_session_ele
|
||||
from ..commons.web import cookie_to_dict, set_session_cookies
|
||||
from ..configs.session_options import SessionOptions
|
||||
|
||||
|
||||
class SessionPage(BasePage):
|
||||
|
@ -9,9 +9,9 @@ from typing import Union
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
|
||||
from .base import BaseElement
|
||||
from DrissionPage.commons.locator import get_loc
|
||||
from .driver_element import make_driver_ele
|
||||
from .session_element import make_session_ele, SessionElement
|
||||
from ..commons.locator import get_loc
|
||||
|
||||
|
||||
class ShadowRootElement(BaseElement):
|
||||
|
24
README.md
24
README.md
@ -30,13 +30,23 @@ python 版本:3.6 及以上
|
||||
|
||||
**📖 使用文档:** [点击查看](https://g1879.gitee.io/drissionpagedocs)
|
||||
|
||||
**交流 QQ 群:** 897838127[已满]、558778073
|
||||
**交流 QQ 群:** 636361957
|
||||
|
||||
---
|
||||
|
||||
# 🔥 新版预告
|
||||
# 🔥 新版尝鲜
|
||||
|
||||
查看下一步开发计划:[新版预告](https://g1879.gitee.io/drissionpagedocs/whatsnew/3_3/)
|
||||
4.0 在 3.x 的基础上对底层进行了大幅重构,新增大量功能,改善运行效率和稳定性,优化项目结构,解决很多存在的问题。对比旧版本有质的提高。
|
||||
|
||||
现已发布 beta 版,欢迎尝鲜。
|
||||
|
||||
[4.0功能介绍](https://g1879.gitee.io/drissionpagedocs/whatsnew/4_0/)
|
||||
|
||||
安装(目前是b14,关注文档,可能会有更新版本):
|
||||
|
||||
```console
|
||||
pip install DrissionPage==4.0.0b14
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@ -108,17 +118,11 @@ python 版本:3.6 及以上
|
||||
|
||||
- 还有很多细节,这里不一一列举,欢迎实际使用中体验:)
|
||||
|
||||
---
|
||||
|
||||
# 🛠 使用文档
|
||||
|
||||
[点击跳转到使用文档](https://g1879.gitee.io/drissionpage)
|
||||
|
||||
---
|
||||
|
||||
# 🔖 版本历史
|
||||
|
||||
[点击查看版本历史](https://g1879.gitee.io/drissionpagedocs/history/3.x/)
|
||||
[点击查看版本历史](https://g1879.gitee.io/drissionpagedocs/history/introduction/)
|
||||
|
||||
---
|
||||
|
||||
|
2
setup.py
2
setup.py
@ -6,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh:
|
||||
|
||||
setup(
|
||||
name="DrissionPage",
|
||||
version="3.2.34",
|
||||
version="3.2.35",
|
||||
author="g1879",
|
||||
author_email="g1879@qq.com",
|
||||
description="Python based web automation tool. It can control the browser and send and receive data packets.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user