mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
修改README
This commit is contained in:
parent
2ea60172ac
commit
30d524f9c5
86
README.en.md
86
README.en.md
@ -7,7 +7,76 @@ Therefore, the convenience of selenium and the high efficiency of requests can b
|
||||
It encapsulates commonly used methods of page elements and is very suitable for the expansion of the PO mode of automated operation.
|
||||
Even better, it is very concise and user-friendly, with little code and friendly to novices.
|
||||
|
||||
**Project address:**
|
||||
|
||||
- https://github.com/g1879/DrissionPage
|
||||
- https://gitee.com/g1879/DrissionPage
|
||||
|
||||
**Demos:** [https://github.com/g1879/DrissionPage-examples](https://github.com/g1879/DrissionPage-examples)
|
||||
|
||||
**email:** g1879@qq.com
|
||||
|
||||
# Features
|
||||
|
||||
***
|
||||
|
||||
-Allows seamless switching between selenium and requests, sharing session.
|
||||
-The two modes provide a unified operation method with consistent user experience.
|
||||
-Common methods are encapsulated in units of pages to facilitate PO mode expansion.
|
||||
-Humanized operation method of page elements to reduce the workload of page analysis and coding.
|
||||
-Save configuration information to file for easy recall.
|
||||
-Some common functions (such as click) have been optimized to better meet the actual needs.
|
||||
|
||||
# Idea
|
||||
|
||||
***
|
||||
|
||||
## Simple, Easy and Extensible
|
||||
|
||||
- DrissionPage takes concise code as the first pursuit, streamlines long statements and completely retains its functions.
|
||||
- DrissionPage encapsulates many commonly used functions and is more convenient to use.
|
||||
- The core of DrissionPage is a page class, which can directly derive subclass pages to adapt to various scenarios.
|
||||
|
||||
The following code implements exactly the same function, comparing the code amounts of the two:
|
||||
|
||||
1、Find all elements whose name is ele_name
|
||||
|
||||
```python
|
||||
# selenium:
|
||||
element = WebDriverWait(driver).until(ec.presence_of_all_elements_located((By.XPATH, '//*[@name="ele_name"]')))
|
||||
# DrissionPage:
|
||||
element = page.eles('@name:ele_name')
|
||||
```
|
||||
|
||||
2、Find the element whose first text contains 'some text'
|
||||
|
||||
```python
|
||||
# selenium:
|
||||
element = WebDriverWait(driver, timeout = 2).until(ec.presence_of_element_located((By.XPATH, '//*[contains(text(), "some text")]')))
|
||||
# DrissionPage:
|
||||
element = page.ele('some text', timeout = 2)
|
||||
```
|
||||
|
||||
3、Jump to the first tab
|
||||
|
||||
```python
|
||||
# selenium
|
||||
driver.switch_to.window(driver.window_handles[0])
|
||||
# DrissionPage
|
||||
page.to_tab(0)
|
||||
```
|
||||
|
||||
4、Drag an element
|
||||
|
||||
```python
|
||||
# selenium
|
||||
ActionChains(driver).drag_and_drop(ele1, ele2).perform()
|
||||
# DrissionPage
|
||||
ele1.drag_to(ele2)
|
||||
```
|
||||
|
||||
# Background
|
||||
|
||||
***
|
||||
|
||||
When a novice learns a web crawler, in the face of a website that needs to log in, it is necessary to analyze data packets, JS source code, construct complex requests, and often have to deal with verification codes, JS confusion, signature parameters and other measures, which is difficult to learn. When acquiring data, some data is generated by JavaScript calculation. If you only get the source data, you must also reproduce the calculation process. The experience is not good and the development efficiency is not high.
|
||||
@ -18,23 +87,6 @@ In addition to merging the two, this library also encapsulates commonly used fun
|
||||
|
||||
The design concept of this library is to keep everything simple, try to provide a simple and direct method of use, and is more friendly to novices.
|
||||
|
||||
**Project address:**
|
||||
|
||||
- https://github.com/g1879/DrissionPage
|
||||
- https://gitee.com/g1879/DrissionPage
|
||||
|
||||
**email:** g1879@qq.com
|
||||
|
||||
# Features
|
||||
***
|
||||
|
||||
-Allows seamless switching between selenium and requests, sharing session.
|
||||
-The two modes provide a unified operation method with consistent user experience.
|
||||
-Common methods are encapsulated in units of pages to facilitate PO mode expansion.
|
||||
-Humanized operation method of page elements to reduce the workload of page analysis and coding.
|
||||
-Save configuration information to file for easy recall.
|
||||
-Some common functions (such as click) have been optimized to better meet the actual needs.
|
||||
|
||||
# Simple Demo
|
||||
|
||||
***
|
||||
|
@ -1,4 +1,5 @@
|
||||
# 简介
|
||||
|
||||
***
|
||||
|
||||
DrissionPage,即driver和session的合体,是个基于python的Web自动化操作集成工具。
|
||||
@ -16,6 +17,67 @@ DrissionPage,即driver和session的合体,是个基于python的Web自动化
|
||||
|
||||
**联系邮箱:** g1879@qq.com
|
||||
|
||||
# 特性
|
||||
|
||||
***
|
||||
|
||||
- 允许在selenium和requests间无缝切换,共享session。
|
||||
- 两种模式提供统一的操作方法,使用体验一致。
|
||||
- 以页面为单位封装常用方法,便于PO模式扩展。
|
||||
- 人性化的页面元素操作方法,减轻页面分析工作量和编码量。
|
||||
- 把配置信息保存到文件,方便调用。
|
||||
- 对某些常用功能(如点击)作了优化,更符合实际使用需要。
|
||||
|
||||
# 理念
|
||||
|
||||
***
|
||||
|
||||
## 简洁、易用 、可扩展
|
||||
|
||||
- DrissionPage以简洁的代码为第一追求,对冗长的语句做了精简,并完全保留了其功能。
|
||||
- DrissionPage封装了许多常用功能,使用更便捷。
|
||||
- DrissionPage的核心是个页面类,可直接派生子类页面,适应各种场景须要。
|
||||
|
||||
以下代码实现一模一样的功能,对比两者的代码量:
|
||||
|
||||
1、查找所有name为ele_name的元素
|
||||
|
||||
```python
|
||||
# selenium:
|
||||
element = WebDriverWait(driver).until(ec.presence_of_all_elements_located((By.XPATH, '//*[@name="ele_name"]')))
|
||||
# DrissionPage:
|
||||
element = page.eles('@name:ele_name')
|
||||
```
|
||||
|
||||
2、查找第一个文本包含some text的元素
|
||||
|
||||
```python
|
||||
# selenium:
|
||||
element = WebDriverWait(driver, timeout = 2).until(ec.presence_of_element_located((By.XPATH, '//*[contains(text(), "some text")]')))
|
||||
# DrissionPage:
|
||||
element = page.ele('some text', timeout = 2)
|
||||
```
|
||||
|
||||
3、跳转到第一个标签页
|
||||
|
||||
```python
|
||||
# selenium
|
||||
driver.switch_to.window(driver.window_handles[0])
|
||||
# DrissionPage
|
||||
page.to_tab(0)
|
||||
```
|
||||
|
||||
4、拖拽一个元素
|
||||
|
||||
```python
|
||||
# selenium
|
||||
ActionChains(driver).drag_and_drop(ele1, ele2).perform()
|
||||
# DrissionPage
|
||||
ele1.drag_to(ele2)
|
||||
```
|
||||
|
||||
|
||||
|
||||
# 背景
|
||||
|
||||
***
|
||||
@ -28,17 +90,6 @@ DrissionPage,即driver和session的合体,是个基于python的Web自动化
|
||||
|
||||
本人学习过程中踩了很多坑,因此这个库的设计理念是一切从简,尽量提供简单直接的使用方法,对新手更友好。
|
||||
|
||||
# 特性
|
||||
|
||||
***
|
||||
|
||||
- 允许在selenium和requests间无缝切换,共享session。
|
||||
- 两种模式提供统一的操作方法,使用体验一致。
|
||||
- 以页面为单位封装常用方法,便于PO模式扩展。
|
||||
- 人性化的页面元素操作方法,减轻页面分析工作量和编码量。
|
||||
- 把配置信息保存到文件,方便调用。
|
||||
- 对某些常用功能(如点击)作了优化,更符合实际使用需要。
|
||||
|
||||
# 简单演示
|
||||
|
||||
***
|
||||
|
Loading…
x
Reference in New Issue
Block a user