ichrome icon indicating copy to clipboard operation
ichrome copied to clipboard

Modify of the Accept header

Open juhacz opened this issue 2 years ago • 1 comments

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.

juhacz avatar Dec 14 '23 21:12 juhacz

  1. maybe it's the feature of httpbin.org, try that use bottle/flask localhost?
  2. update new headers can be done with Fetch

ClericPy avatar Jan 09 '24 13:01 ClericPy