1. add webapp route for /request_get to send get request with headers,proxy
python
======================= server code ===========================
from inspect import getsource
import requests
1. request_get demo
print(
requests.get(
"http://127.0.0.1:8009/chrome/request_get",
params={
"__url": "http://httpbin.org/get?a=1", # [required] target URL
"__proxy": "http://127.0.0.1:1080", # [optional]
"__timeout": "10", [optional]
"my_query": "OK", [optional] params for target URL
},
headers for target URL
headers={
"User-Agent": "OK",
"my_header": "OK",
"Cookie": "my_cookie1=OK",
},
cookies={"my_cookie2": "OK"}, [optional] cookies for target URL if headers["Cookie"] is None
).text,
flush=True,
)
<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">{
"args": {
"a": "1",
"my_query": "OK"
},
"headers": {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Accept-Encoding": "gzip, deflate",
"Cookie": "my_cookie1=OK",
"Host": "httpbin.org",
"My-Header": "OK",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "OK",
"X-Amzn-Trace-Id": "Root=1-654d0664-74457b4317c2f41d17b6a823"
},