"url": "http://httpbin.org/get?a=1&my_query=OK"
}
</pre></body></html>
'"Herman Melville - Moby-Dick"'
"<html><head><meta name=\"color-scheme\" content=\"light dark\"></head><body><pre style=\"word-wrap: break-word; white-space: pre-wrap;\">{\n \"origin\": \"103.171.177.94\"\n}\n</pre></body></html>"
2. test tab_callback
async def tab_callback(self, tab, data, timeout):
await tab.set_url(data["url"], timeout=timeout)
return (await tab.querySelector("h1")).text
r = requests.post(
"http://127.0.0.1:8009/chrome/do",
json={
"data": {"url": "http://httpbin.org/html"},
"tab_callback": getsource(tab_callback),
"timeout": 10,
},
)
print(repr(r.text), flush=True)
'"Herman Melville - Moby-Dick"'
async def tab_callback(task, tab, data, timeout):
await tab.wait_loading(3)
return await tab.html
3. incognito_args demo
print(
requests.post(
"http://127.0.0.1:8009/chrome/do",
json={
"tab_callback": getsource(tab_callback),
"timeout": 10,
"incognito_args": {
"url": "http://httpbin.org/ip",
"proxyServer": "http://127.0.0.1:1080",
},
},
).text
)
"<html><head><meta name=\"color-scheme\" content=\"light dark\"></head><body><pre style=\"word-wrap: break-word; white-space: pre-wrap;\">{\n \"origin\": \"103.171.177.94\"\n}\n</pre></body></html>"