From af675c8a8e90cbac63c708a26604eeaf32a3d5fe Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 5 Jun 2020 18:36:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 156 +++++++++++++++++++++++++++++++++++++++++------- README.zh-cn.md | 118 +++++++++++++++++++++++++++++++++++- 2 files changed, 249 insertions(+), 25 deletions(-) diff --git a/README.en.md b/README.en.md index 99e3b7e..e0d8481 100644 --- a/README.en.md +++ b/README.en.md @@ -1005,6 +1005,24 @@ Parameter Description: ​ Returns the last sibling element object. +### parents + +​ parents(num: int = 1) -> Union[DriverElement, None] + +​ Returns the Nth-level parent element object. + +### nexts + +​ nexts(num: int = 1) -> Union[DriverElement, None] + +​ Returns the next N sibling element objects. + +### prevs + +​ prevs(num: int = 1) -> Union[DriverElement, None] + +​ Return the first N sibling element objects. + ### size ​ Returns the element size as a dictionary. @@ -1213,6 +1231,24 @@ Parameter Description: ​ Returns the last sibling element object. +### parents + +​ parents(num: int = 1) -> Union[DriverElement, None] + +​ Returns the Nth-level parent element object. + +### nexts + +​ nexts(num: int = 1) -> Union[DriverElement, None] + +​ Returns the next N sibling element objects. + +### prevs + +​ prevs(num: int = 1) -> Union[DriverElement, None] + +​ Return the first N sibling element objects. + ### ele ​ ele(loc_or_str: Union[tuple, str], mode: str = None, show_errmsg: bool = False) -> Union[SessionElement, List[SessionElement], None] @@ -1365,40 +1401,116 @@ Parameter Description: -## Useful methods +- ## easy_set methods -### set_paths + The configuration of chrome is too difficult to remember, so the commonly used configuration is written as a simple method, and the call will modify the relevant content of the ini file. -​ set_paths(driver_path: str = None, chrome_path: str = None, debugger_address: str = None, global_tmp_path: str = None, download_path: str = None, check_version: bool = True) -> None + ### set_paths -​ Convenient way to set the path, save the incoming path to the default ini file, and check whether the chrome and chromedriver versions match. + ​ set_paths(driver_path: str = None, chrome_path: str = None, debugger_address: str = None, global_tmp_path: str = None, download_path: str = None, user_data_path: str = None, cache_path: str = None, check_version: bool = True) -> None -​ Parameter Description: + ​ Convenient way to set the path, save the incoming path to the default ini file, and check whether the chrome and chromedriver versions match. -- driver_path - chromedriver.exe path -- chrome_path - chrome.exe path -- debugger_address - Debug browser address, for example: 127.0.0.1:9222 -- download_path - Download path -- global_tmp_path - Temporary folder path -- check_version - Whether to check whether chromedriver and chrome match + ​ Parameter Description: -### set_headless + - driver_path - the path of chromedriver.exe + - chrome_path - the path of chrome.exe + - debugger_address - Debug browser address, eg. 127.0.0.1:9222 + - download_path - File download path + - global_tmp_path - Temporary folder path + - user_data_path - User data path + - cache_path - Cache path + - check_version - Whether to check whether chromedriver and chrome match -​ set_headless(on_off: bool) -> None + ### set_value_argument -​ Convenient headless switch. + ​ set_value_argument(arg: str, value: str) -> None -​ Parameter Description: + ​ Set valued attributes. -- on_off - Whether to enable headless mode + ​ Parameter Description: -### check_driver_version + - arg - Attribute name + - value - Attribute value -​ check_driver_version(driver_path: str = None, chrome_path: str = None) -> bool + ### set_argument -​ Check if the chrome and chromedriver versions match. + ​ set_argument(arg: str, on_off: bool) -> None -​ Parameter Description: + ​ Set an attribute with no value. -- driver_path - chromedriver.exe path -- chrome_path - chrome.exe path \ No newline at end of file + ​ Parameter Description: + + - arg - Attribute name + - on_off - On or off + + ### set_headless + + ​ set_headless(on_off: bool) -> None + + ​ Turn headless mode on or off. + + ​ Parameter Description: + + - on_off - Whether to enable headless mode + + ### set_no_imgs + + ​ set_no_imgs(on_off: bool) -> None + + ​ Turn the picture display on or off. + + ​ Parameter Description: + + - on_off - Whether to enable no-picture mode + + ### set_no_js + + ​ set_no_js(on_off: bool) -> None + + ​ Turn JS mode on or off. + + ​ Parameter Description: + + - on_off - Whether to enable or disable JS mode + + ### set_mute + + ​ set_mute(on_off: bool) -> None + + ​ Turn silent mode on or off. + + ​ Parameter Description: + + - on_off - Whether to turn on silent mode + + ### set_user_agent + + ​ set_user_agent(user_agent: str) -> None: + + ​ Set user_agent. + + ​ Parameter Description: + + - user_agent - user_agent value + + ### set_proxy + + ​ set_proxy(proxy: str) -> None + + ​ Set up the proxy. + + ​ Parameter Description: + + - proxy - Proxy value + + ### check_driver_version + + ​ check_driver_version(driver_path: str = None, chrome_path: str = None) -> bool + + ​ Check if the chrome and chromedriver versions match. + + ​ Parameter Description: + + - driver_path - the path of chromedriver.exe + - chrome_path - the path of chrome.exe \ No newline at end of file diff --git a/README.zh-cn.md b/README.zh-cn.md index 4c75c15..a147ef4 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -1001,6 +1001,24 @@ driver模式的元素对象,包装了一个WebElement对象,并封装了常 ​ 返回上一个兄弟元素对象。 +### parents + +​ parents(num: int = 1) -> Union[DriverElement, None] + +​ 返回第N层父级元素对象。 + +### nexts + +​ nexts(num: int = 1) -> Union[DriverElement, None] + +​ 返回下N个兄弟元素对象。 + +### prevs + +​ prevs(num: int = 1) -> Union[DriverElement, None] + +​ 返回前N个兄弟元素对象。 + ### size ​ 以字典方式返回元素大小。 @@ -1209,6 +1227,24 @@ session模式的元素对象,包装了一个Element对象,并封装了常用 ​ 返回上一个兄弟元素对象。 +### parents + +​ parents(num: int = 1) -> Union[DriverElement, None] + +​ 返回第N层父级元素对象。 + +### nexts + +​ nexts(num: int = 1) -> Union[DriverElement, None] + +​ 返回下N个兄弟元素对象。 + +### prevs + +​ prevs(num: int = 1) -> Union[DriverElement, None] + +​ 返回前N个兄弟元素对象。 + ### ele ​ ele(loc_or_str: Union[tuple, str], mode: str = None, show_errmsg: bool = False) -> Union[SessionElement, List[SessionElement], None] @@ -1361,11 +1397,13 @@ session模式的元素对象,包装了一个Element对象,并封装了常用 -## 有用的方法 +## easy_set方法 + +chrome的配置太难记,所以把常用的配置写成简单的方法,调用会修改ini文件相关内容。 ### set_paths -​ set_paths(driver_path: str = None, chrome_path: str = None, debugger_address: str = None, global_tmp_path: str = None, download_path: str = None, check_version: bool = True) -> None +​ set_paths(driver_path: str = None, chrome_path: str = None, debugger_address: str = None, global_tmp_path: str = None, download_path: str = None, user_data_path: str = None, cache_path: str = None, check_version: bool = True) -> None ​ 便捷的设置路径方法,把传入的路径保存到默认ini文件,并检查chrome和chromedriver版本是否匹配。 @@ -1376,18 +1414,92 @@ session模式的元素对象,包装了一个Element对象,并封装了常用 - debugger_address - 调试浏览器地址,例:127.0.0.1:9222 - download_path - 下载文件路径 - global_tmp_path - 临时文件夹路径 +- user_data_path - 用户数据路径 +- cache_path - 缓存路径 - check_version - 是否检查chromedriver和chrome是否匹配 +### set_value_argument + +​ set_value_argument(arg: str, value: str) -> None + +​ 设置有值的属性。 + +​ 参数说明: + +- arg - 属性名 +- value - 属性值 + +### set_argument + +​ set_argument(arg: str, on_off: bool) -> None + +​ 设置没有值的属性。 + +​ 参数说明: + +- arg - 属性名 +- on_off - 开或关 + ### set_headless ​ set_headless(on_off: bool) -> None -​ 便捷的headless开关。 +​ 开启或关闭headless模式。 ​ 参数说明: - on_off - 是否开启headless模式 +### set_no_imgs + +​ set_no_imgs(on_off: bool) -> None + +​ 开启或关闭图片显示。 + +​ 参数说明: + +- on_off - 是否开启无图模式 + +### set_no_js + +​ set_no_js(on_off: bool) -> None + +​ 开启或关闭禁用JS模式。 + +​ 参数说明: + +- on_off - 是否开启禁用JS模式 + +### set_mute + +​ set_mute(on_off: bool) -> None + +​ 开启或关闭静音模式。 + +​ 参数说明: + +- on_off - 是否开启静音模式 + +### set_user_agent + +​ set_user_agent(user_agent: str) -> None: + +​ 设置user_agent。 + +​ 参数说明: + +- user_agent - user_agent值 + +### set_proxy + +​ set_proxy(proxy: str) -> None + +​ 设置代理。 + +​ 参数说明: + +- proxy - 代理值 + ### check_driver_version ​ check_driver_version(driver_path: str = None, chrome_path: str = None) -> bool