Files
wiki/mitmproxy/README.md
2025-12-04 20:57:28 +09:00

49 lines
1.7 KiB
Markdown

# `dump.py`
```python
I = lambda module: __import__('importlib').import_module(module)
def request(flow):
with I('dbm.sqlite3').open('dbm.sql') as db:
if (url := flow.request.url) in db:
flow.response = I('mitmproxy.http').Response.make(200, db[url])
def response(flow):
if flow.response.status_code == 200:
with I('dbm.sqlite3').open('dbm.sql', 'c') as db:
db[flow.request.url] = flow.response.content
if __name__ == '__main__':
I('subprocess').run(['mitmdump', '-s', __file__])
```
# Retries if failed
```python
def response(flow):
retries = 0
while flow.response.status_code != 206:
retries += 1
flow.response = flow.replay().response
print(f"재시도 {retries}: 상태 코드 {flow.response.status_code}")
```
```python
for idx, line in enumerate(open('m3u8').readlines()):
os.system(f"ffmpeg -y -http_proxy http://localhost:8080 -i '{line.strip()}' -c:v copy -c:a copy {idx+1:02}.mp4")
```
---
```shell
mitmweb
```
```shell
playwright ff --proxy-server http://localhost:8080 --ignore-https-errors
```
```shell
chromium --proxy-server=localhost:8080 --ignore-certificate-errors --disable-backgrounding-occluded-windows
```
```shell
chromium --proxy-server=172.17.112.1:8080 --ignore-certificate-errors --remote-debugging-port=9222 --remote-allow-origins=* --user-agent="Mozilla/5.0 (Linux; Android 15) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.6834.122 Mobile Safari/537.36"
```
```shell
chrome --proxy-server=localhost:8080 --ignore-certificate-errors --disable-backgrounding-occluded-windows --user-agent="Mozilla/5.0 (Linux; Android 15) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.6834.122 Mobile Safari/537.36"
```