-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathudemy_proxy.py
More file actions
23 lines (19 loc) · 1 KB
/
udemy_proxy.py
File metadata and controls
23 lines (19 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
mitmproxy addon to make requests look like they come from a real browser
Usage: mitmproxy -s udemy_proxy.py --listen-port 8888
"""
from mitmproxy import http
class UdemyProxy:
def request(self, flow: http.HTTPFlow) -> None:
# Only modify requests to Udemy
if "udemy.com" in flow.request.pretty_host:
# Add browser-like headers
flow.request.headers["sec-ch-ua"] = '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"'
flow.request.headers["sec-ch-ua-mobile"] = "?0"
flow.request.headers["sec-ch-ua-platform"] = '"macOS"'
flow.request.headers["sec-fetch-dest"] = "empty"
flow.request.headers["sec-fetch-mode"] = "cors"
flow.request.headers["sec-fetch-site"] = "same-origin"
# Upgrade user agent
flow.request.headers["user-agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
addons = [UdemyProxy()]