Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify of the Accept header #145

Open
juhacz opened this issue Dec 14, 2023 · 1 comment
Open

Modify of the Accept header #145

juhacz opened this issue Dec 14, 2023 · 1 comment

Comments

@juhacz
Copy link

juhacz commented Dec 14, 2023

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 juhacz changed the title Modification of the Accept header Modify of the Accept header Dec 14, 2023
@ClericPy
Copy link
Owner

ClericPy commented Jan 9, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants