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

[BUG] Can't impersonate browsers in flatpak #362

Open
FrancescoCaracciolo opened this issue Aug 3, 2024 · 8 comments
Open

[BUG] Can't impersonate browsers in flatpak #362

FrancescoCaracciolo opened this issue Aug 3, 2024 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@FrancescoCaracciolo
Copy link

Describe the bug
With curl_cffi 0.7.1, when I try to impersonate a browser, it gives this error: (happens with every browser)

  File "/app/lib/python3.11/site-packages/curl_cffi/requests/session.py", line 581, in _set_curl_options
    raise RequestsError(f"Impersonating {impersonate} is not supported")
curl_cffi.requests.errors.RequestsError: Impersonating BrowserType.chrome124 is not supported

Note: this does not happen when I run curl_cffi on my system normally.

To Reproduce
Within the flatpak in Newelle source code, just running

from curl_cffi import requests

r = requests.get("https://tools.scrapfly.io/api/fp/ja3", impersonate="chrome124")

or with any other browser, it gives the error
Expected behavior
It just works

Versions

  • OS: Arch Linux x64 under Flatpak with
  • curl_cffi 0.7.1
  • pip freeze dump
aiohappyeyeballs==2.3.4
aiohttp==3.10.0
aiosignal==1.3.1
attrs==23.2.0
Brotli==1.1.0
certifi==2024.7.4
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
curl_cffi==0.7.1
Cython==0.29.37
expandvars==0.12.0
frozenlist==1.4.1
g4f==0.3.2.3
gpt4all==2.7.0
gTTS==2.5.1
idna==3.7
Jinja2==3.1.4
lxml==5.2.2
Mako==1.3.5
Markdown==3.6
MarkupSafe==2.1.5
meson==1.3.2
multidict==6.0.5
packaging==24.1
playsound==1.3.0
PyAudio==0.2.14
pycairo==1.26.1
pycparser==2.21
pycryptodome==3.20.0
Pygments==2.18.0
PyGObject==3.48.2
requests==2.32.3
six==1.16.0
SpeechRecognition==3.10.4
tqdm==4.66.4
typing_extensions==4.12.2
urllib3==2.2.2
yarl==1.9.4
@FrancescoCaracciolo FrancescoCaracciolo added the bug Something isn't working label Aug 3, 2024
@perklet
Copy link
Collaborator

perklet commented Aug 3, 2024

Weird, can you somehow unpack the bundle and check if the files were correctly included?

@FrancescoCaracciolo
Copy link
Author

For what file should I look for? impresonate.py is there and is correct

@perklet
Copy link
Collaborator

perklet commented Aug 3, 2024

Does it work without the impersonate parameter?

@FrancescoCaracciolo
Copy link
Author

Yes

@perklet
Copy link
Collaborator

perklet commented Aug 5, 2024

That's even more weird, do you have any additional information?

@FrancescoCaracciolo
Copy link
Author

FrancescoCaracciolo commented Aug 5, 2024

I don't know what could be the issue either. It is possible that it is related to sandboxing?

@chocolateboy
Copy link

chocolateboy commented Dec 17, 2024

I have a similar issue with the Arch package (no Flatpak), which is currently on v0.7.1:

from curl_cffi import requests

BROWSERS = [
    'chrome99',
    'chrome99_android',
    'chrome100',
    'chrome101',
    'chrome104',
    'chrome107',
    'chrome110',
    'chrome116',
    'chrome119',
    'chrome120',
    'chrome123',
    'chrome124',
    'edge99',
    'edge101',
    'safari15_3',
    'safari15_5',
    'safari17_0',
    'safari17_2_ios',
]

HOST = 'http://localhost:8080'

for browser in BROWSERS:
    status = 'ok'

    try:
        requests.get(HOST, impersonate=browser)
    except Exception:
        status = 'error'

    print(f'{browser}: {status}')
browser status
chrome99_android ok
chrome100 ok
chrome101 ok
chrome104 ok
chrome107 ok
chrome110 ok
chrome116 ok
chrome119 error
chrome120 error
chrome123 error
chrome124 error
edge99 ok
edge101 ok
safari15_3 ok
safari15_5 ok
safari17_0 error
safari17_2_ios error

The error in each case is Impersonating <browser> is not supported.

OS: Arch Linux x86_64
python: 3.12.7
curl_cffi: v0.7.1

@lexiforest
Copy link
Owner

lexiforest commented Dec 18, 2024

Sorry, I don't have control over 3rd-party packages. Supported browser versions are listed on the README page, which clearly shows that some of your items here are not supported in 0.7.1. You can either use the latest version from PyPI or ask the maintainer of the Arch package to update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants