ichrome
ichrome copied to clipboard
Modify of the Accept header
Is it possible to modify the Accept header sent by the browser? I need to modify the Accept header.
import asyncio
from ichrome import AsyncChromeDaemon
async def test():
async with AsyncChromeDaemon() as cd:
# create a new tab
async with cd.connect_tab(index=None) as tab:
await tab.set_headers({"Accept": "application/vnd.opbox-web.v2+json"})
await tab.goto('https://httpbin.org/headers', timeout=5)
print(await tab.html)
asyncio.run(test())
The above program does nothing when I change the line
await tab.set_headers({"Accept2": "application/vnd.opbox-web.v2+json"})
the Accept2 header is correctly addeded, strangely enough when I change the lines to
await tab.set_headers({"User-Agent": "application/vnd.opbox-web.v2+json"})
User Agent is changed, but this does not work in the case of the Accept header.
- maybe it's the feature of httpbin.org, try that use bottle/flask localhost?
- update new headers can be done with
Fetch