初始化仓库
This commit is contained in:
commit
46360a383b
70
.gitignore
vendored
Normal file
70
.gitignore
vendored
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# IDE settings
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# Project specific
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
.DS_Store
|
10
README.MD
Normal file
10
README.MD
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
### 项目依赖安装
|
||||||
|
```shell
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
### requirements.txt
|
||||||
|
```shell
|
||||||
|
pip install pipreqs
|
||||||
|
pipreqs ./ --encoding=utf8
|
||||||
|
```
|
53
main.py
Normal file
53
main.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
from DrissionPage import Chromium, ChromiumOptions, SessionPage
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
import atexit
|
||||||
|
import json
|
||||||
|
|
||||||
|
options = ChromiumOptions()
|
||||||
|
# 无头模式
|
||||||
|
# options.headless()
|
||||||
|
|
||||||
|
browser = Chromium(options)
|
||||||
|
tab = browser.latest_tab
|
||||||
|
|
||||||
|
|
||||||
|
def console_listener(tab):
|
||||||
|
# 监听控制台
|
||||||
|
tab.console.start()
|
||||||
|
steps = tab.console.steps()
|
||||||
|
for log in steps:
|
||||||
|
# print("[console.log]", log)
|
||||||
|
print(f"[console.log] {log.text}")
|
||||||
|
|
||||||
|
def network_listener(tab):
|
||||||
|
# 监听网络
|
||||||
|
tab.listen.start(targets="192.168.31.139:8126")
|
||||||
|
for log in tab.listen.steps():
|
||||||
|
try:
|
||||||
|
# print("[network.log]", log)
|
||||||
|
print(vars(log))
|
||||||
|
# request = json.dumps(log.request)
|
||||||
|
# print(request)
|
||||||
|
# response = json.dumps(log.response)
|
||||||
|
print(f"[network.log] {log.method} {log.url} {'request'} {''}")
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
executor = ThreadPoolExecutor(max_workers=2)
|
||||||
|
executor.submit(console_listener, tab)
|
||||||
|
executor.submit(network_listener, tab)
|
||||||
|
|
||||||
|
tab.get(url='http://127.0.0.1:8080/pages/index/shopIndex')
|
||||||
|
tab.change_mode()
|
||||||
|
|
||||||
|
|
||||||
|
items = tab.eles("t:body")
|
||||||
|
for item in items:
|
||||||
|
print(item)
|
||||||
|
|
||||||
|
def exit():
|
||||||
|
print('exit')
|
||||||
|
browser.quit()
|
||||||
|
executor.shutdown()
|
||||||
|
|
||||||
|
atexit.register(exit)
|
Loading…
Reference in New Issue
Block a user