# SaossionPage[骚神库]
![logo](https://wxhzhwxhzh.github.io/saossion_code_helper_online/img/saoshen2.png)
[![Downloads](https://static.pepy.tech/badge/SaossionPage)](https://pepy.tech/project/SaossionPage)
The brother version of the Drissionpage library, SaossionPage, is referred to as Sao Shen for short
## Installation
```
pip install SaossionPage
```
## Usage
example 1: Print the tree structure of the element tag
```python
from SaossionPage import Browser
if __name__ == '__main__':
browser = Browser(config=" ")
browser.open('https://www.doc88.com/')
t=browser.page.latest_tab
y=t.ele('t:body')
t.wait(2)
# 打印元素标签的树结构
browser.get_tree(y)
input(' press any key to exit')
```
example 2: Convert native HTML tag syntax to DP library element syntax
```python
#将原生html标签语法转换成DP库元素语法
from SaossionPage import Browser,Use
if __name__ == '__main__':
#连接浏览器
b=Browser()
t=b.page.new_tab('https://www.baidu.com/')
#获取元素
search_botton=t.ele(Use.raw('<input type="submit" id="su" value="百度一下" class="bg s_btn">'))
print(search_botton)
input(' press any key to exit')
```
example 3: Foolish browser startup configuration
```python
# 傻瓜式浏览器启动配置
from SaossionPage import Browser
if __name__ == '__main__':
# 连接浏览器 傻瓜式自动识别配置
browser = Browser( r"C:\Users\Application\chrome.exe",config=' 静音 无图 代理http://127.0.0.1:1080 ')
# 打开网站
browser.open('https://www.bing.com/')
input(' press any key to exit')
```
example 4: High-definition element screenshots
```python
# 高清元素截图
from SaossionPage import Browser
if __name__ == '__main__':
browser = Browser(config=" ")
browser.open('https://www.python.org/')
t=browser.page.latest_tab
y=t.ele('t:body')
t.wait(2)
# 截图
browser.get_shot_by_canvas(tab=t,ele=y,name='shot.png')
input(' press any key to exit')
```
example 5: # Extract JSON data returned by asynchronous function
```python
# 提取异步函数返回的json数据
from SaossionPage import Browser,Tool
if __name__ == '__main__':
browser = Browser(config=' ')
url='https://spa3.scrape.center/'
tab=browser.page.new_tab(url)
js_code=r'''fetch("https://spa3.scrape.center/api/movie/?limit=10&offset=0", {
"referrer": "https://spa3.scrape.center/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "omit"
});
'''
aa=Tool.get_json_by_js_fetch(tab=tab,fetch_code=js_code)
print(aa)
input(' press any key to exit')
```
example 6: # 支持上下文管理协议的 new_page
```python
# 支持上下文管理协议的 new_page
from SaossionPage import Browser
if __name__ == '__main__':
browser=Browser()
with browser.new_page('https://tencent.com/') as t:
print(t.title)
input('press any to continue...')
```
example 7: # 新增浏览器控制台Drissionpage语法反向调试模式
```python
# 浏览器控制台Drissionpage语法反向调试模式
from SaossionPage import Tool
from DrissionPage import Chromium
# 创建页面对象
tab = Chromium().latest_tab
# 访问网页
tab.get("https://www.baidu.com/")
# 暂停,进入语法调试模式,此时打开debtool ,在控制台输入语法即可执行 例如 eles("t:div")
Tool.pause(tab)
input('继续 ?')
```
## Update log
- `1.0.7` add Tool.pause
- `1.0.6` fix bug
- `1.0.5` add NewPage the context manager
- `1.0.4` add fetch_code
- `1.0.3` add logo
- `1.0.2` update README.md
- `1.0.1` fix bug
- `1.0.0` first release
Raw data
{
"_id": null,
"home_page": null,
"name": "SaossionPage",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, menu, saoshen, windows, SaossionPage, linux",
"author": "sao shen",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/b2/e6/4e9acd18f7734862433b56a60b3f4fa7c96690ef2719aba46eaded153887/SaossionPage-1.0.7.tar.gz",
"platform": null,
"description": "\r\n# SaossionPage[\u9a9a\u795e\u5e93]\r\r\n![logo](https://wxhzhwxhzh.github.io/saossion_code_helper_online/img/saoshen2.png)\r\r\n\r\r\n[![Downloads](https://static.pepy.tech/badge/SaossionPage)](https://pepy.tech/project/SaossionPage)\r\r\n\r\r\nThe brother version of the Drissionpage library, SaossionPage, is referred to as Sao Shen for short\r\r\n\r\r\n\r\r\n## Installation\r\r\n\r\r\n```\r\r\npip install SaossionPage\r\r\n```\r\r\n\r\r\n\r\r\n\r\r\n## Usage\r\r\n\r\r\n example 1: Print the tree structure of the element tag\r\r\n\r\r\n\r\r\n```python\r\r\n\r\r\nfrom SaossionPage import Browser\r\r\n\r\r\n\r\r\nif __name__ == '__main__':\r\r\n browser = Browser(config=\" \")\r\r\n\r\r\n browser.open('https://www.doc88.com/')\r\r\n\r\r\n t=browser.page.latest_tab\r\r\n y=t.ele('t:body')\r\r\n t.wait(2) \r\r\n # \u6253\u5370\u5143\u7d20\u6807\u7b7e\u7684\u6811\u7ed3\u6784\r\r\n browser.get_tree(y) \r\r\n\r\r\n input(' press any key to exit')\r\r\n\r\r\n```\r\r\nexample 2: Convert native HTML tag syntax to DP library element syntax\r\r\n\r\r\n\r\r\n```python\r\r\n#\u5c06\u539f\u751fhtml\u6807\u7b7e\u8bed\u6cd5\u8f6c\u6362\u6210DP\u5e93\u5143\u7d20\u8bed\u6cd5\r\r\nfrom SaossionPage import Browser,Use\r\r\n\r\r\n\r\r\nif __name__ == '__main__':\r\r\n #\u8fde\u63a5\u6d4f\u89c8\u5668\r\r\n b=Browser()\r\r\n t=b.page.new_tab('https://www.baidu.com/')\r\r\n #\u83b7\u53d6\u5143\u7d20\r\r\n\r\r\n search_botton=t.ele(Use.raw('<input type=\"submit\" id=\"su\" value=\"\u767e\u5ea6\u4e00\u4e0b\" class=\"bg s_btn\">'))\r\r\n \r\r\n print(search_botton)\r\r\n\r\r\n input(' press any key to exit')\r\r\n\r\r\n```\r\r\n\r\r\nexample 3: Foolish browser startup configuration\r\r\n\r\r\n\r\r\n```python\r\r\n# \u50bb\u74dc\u5f0f\u6d4f\u89c8\u5668\u542f\u52a8\u914d\u7f6e\r\r\nfrom SaossionPage import Browser\r\r\n\r\r\n\r\r\nif __name__ == '__main__':\r\r\n\r\r\n # \u8fde\u63a5\u6d4f\u89c8\u5668 \u50bb\u74dc\u5f0f\u81ea\u52a8\u8bc6\u522b\u914d\u7f6e\r\r\n browser = Browser( r\"C:\\Users\\Application\\chrome.exe\",config=' \u9759\u97f3 \u65e0\u56fe \u4ee3\u7406http://127.0.0.1:1080 ')\r\r\n\r\r\n # \u6253\u5f00\u7f51\u7ad9 \r\r\n browser.open('https://www.bing.com/') \r\r\n\r\r\n input(' press any key to exit')\r\r\n\r\r\n```\r\r\nexample 4: High-definition element screenshots\r\r\n\r\r\n\r\r\n```python\r\r\n# \u9ad8\u6e05\u5143\u7d20\u622a\u56fe\r\r\nfrom SaossionPage import Browser\r\r\n\r\r\nif __name__ == '__main__':\r\r\n browser = Browser(config=\" \")\r\r\n\r\r\n browser.open('https://www.python.org/')\r\r\n t=browser.page.latest_tab\r\r\n y=t.ele('t:body')\r\r\n t.wait(2)\r\r\n \r\r\n # \u622a\u56fe\r\r\n browser.get_shot_by_canvas(tab=t,ele=y,name='shot.png') \r\r\n\r\r\n\r\r\n\r\r\n input(' press any key to exit')\r\r\n\r\r\n```\r\r\nexample 5: # Extract JSON data returned by asynchronous function\r\r\n\r\r\n\r\r\n```python\r\r\n# \u63d0\u53d6\u5f02\u6b65\u51fd\u6570\u8fd4\u56de\u7684json\u6570\u636e\r\r\nfrom SaossionPage import Browser,Tool\r\r\n\r\r\nif __name__ == '__main__':\r\r\n browser = Browser(config=' ')\r\r\n url='https://spa3.scrape.center/'\r\r\n tab=browser.page.new_tab(url) \r\r\n js_code=r'''fetch(\"https://spa3.scrape.center/api/movie/?limit=10&offset=0\", {\r\r\n \"referrer\": \"https://spa3.scrape.center/\",\r\r\n \"referrerPolicy\": \"strict-origin-when-cross-origin\",\r\r\n \"body\": null,\r\r\n \"method\": \"GET\",\r\r\n \"mode\": \"cors\",\r\r\n \"credentials\": \"omit\"\r\r\n });\r\r\n '''\r\r\n \r\r\n\r\r\n aa=Tool.get_json_by_js_fetch(tab=tab,fetch_code=js_code) \r\r\n print(aa) \r\r\n\r\r\n\r\r\n input(' press any key to exit')\r\r\n\r\r\n```\r\r\nexample 6: # \u652f\u6301\u4e0a\u4e0b\u6587\u7ba1\u7406\u534f\u8bae\u7684 new_page\r\r\n\r\r\n\r\r\n\r\r\n```python\r\r\n# \u652f\u6301\u4e0a\u4e0b\u6587\u7ba1\u7406\u534f\u8bae\u7684 new_page\r\r\nfrom SaossionPage import Browser\r\r\n\r\r\nif __name__ == '__main__':\r\r\n browser=Browser()\r\r\n with browser.new_page('https://tencent.com/') as t:\r\r\n print(t.title)\r\r\n\r\r\n input('press any to continue...') \r\r\n\r\r\n```\r\r\nexample 7: # \u65b0\u589e\u6d4f\u89c8\u5668\u63a7\u5236\u53f0Drissionpage\u8bed\u6cd5\u53cd\u5411\u8c03\u8bd5\u6a21\u5f0f\r\r\n\r\r\n\r\r\n\r\r\n```python\r\r\n# \u6d4f\u89c8\u5668\u63a7\u5236\u53f0Drissionpage\u8bed\u6cd5\u53cd\u5411\u8c03\u8bd5\u6a21\u5f0f\r\r\nfrom SaossionPage import Tool\r\r\nfrom DrissionPage import Chromium\r\r\n\r\r\n# \u521b\u5efa\u9875\u9762\u5bf9\u8c61\r\r\ntab = Chromium().latest_tab\r\r\n# \u8bbf\u95ee\u7f51\u9875\r\r\ntab.get(\"https://www.baidu.com/\")\r\r\n # \u6682\u505c\uff0c\u8fdb\u5165\u8bed\u6cd5\u8c03\u8bd5\u6a21\u5f0f\uff0c\u6b64\u65f6\u6253\u5f00debtool \uff0c\u5728\u63a7\u5236\u53f0\u8f93\u5165\u8bed\u6cd5\u5373\u53ef\u6267\u884c \u4f8b\u5982 eles(\"t:div\")\r\r\nTool.pause(tab) \r\r\n\r\r\ninput('\u7ee7\u7eed ?') \r\r\n\r\r\n```\r\r\n\r\r\n\r\r\n\r\r\n## Update log\r\r\n\r\r\n\r\r\n\r\r\n- `1.0.7` add Tool.pause\r\r\n- `1.0.6` fix bug\r\r\n- `1.0.5` add NewPage the context manager\r\r\n- `1.0.4` add fetch_code\r\r\n- `1.0.3` add logo\r\r\n- `1.0.2` update README.md\r\r\n- `1.0.1` fix bug\r\r\n- `1.0.0` first release\r\r\n\r\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A sao shen library",
"version": "1.0.7",
"project_urls": null,
"split_keywords": [
"python",
" menu",
" saoshen",
" windows",
" saossionpage",
" linux"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b2e64e9acd18f7734862433b56a60b3f4fa7c96690ef2719aba46eaded153887",
"md5": "22417a0454203276a641431556051f1f",
"sha256": "2f60828549e1323e1329e4077ff433c073735c8a3f97c61b0126cc58c73f4689"
},
"downloads": -1,
"filename": "SaossionPage-1.0.7.tar.gz",
"has_sig": false,
"md5_digest": "22417a0454203276a641431556051f1f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 99580,
"upload_time": "2024-11-21T12:02:22",
"upload_time_iso_8601": "2024-11-21T12:02:22.067174Z",
"url": "https://files.pythonhosted.org/packages/b2/e6/4e9acd18f7734862433b56a60b3f4fa7c96690ef2719aba46eaded153887/SaossionPage-1.0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-21 12:02:22",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "saossionpage"
}