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

Bank Hapoalim API requires a functional cookie #166

Open
jond01 opened this issue Feb 10, 2024 · 0 comments
Open

Bank Hapoalim API requires a functional cookie #166

jond01 opened this issue Feb 10, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jond01
Copy link
Owner

jond01 commented Feb 10, 2024

After a few requests from the same IP, the following URL is blocked:
https://www.bankhapoalim.co.il/he/coin-rates
With the following uninformative error:

urllib.error.HTTPError: HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Found

Try with:

import pandas as pd

pd.read_json("https://www.bankhapoalim.co.il/he/coin-rates")

Run it a few times.

After a quick research, I found the following cookies are required ("functional" cookies): incap_ses_***_*******.
One can get them from a web-browser.
For example, the following currently works for me:

pd.read_json(
    "https://www.bankhapoalim.co.il/he/coin-rates",
    storage_options={
        "Cookie": " ".join(
            """\
incap_ses_1255_2405596=a/GzCf3fvnceYM2cLahqEUXj6mUAAAAAtfv8l97VCsPJsew65Qa8XA==;
incap_ses_1255_2405249=DKE/HuRYLSgUMtWcLahqEf/t6mUAAAAArYjjw97q1DiiXLULf6cJJw==;
incap_ses_1255_2405640=wc+ZOPCR9VzEeB+dLahqEfF762UAAAAAk7Vee7dBohFS/K9LTiy3wg==
            """.splitlines()
        )
    },
)

Only the last one is necessary.

We need to find a way to overcome it or allow users to insert their cookie conveniently.

@jond01 jond01 added the bug Something isn't working label Feb 10, 2024
jond01 added a commit that referenced this issue Mar 9, 2024
Otherwise, it fails sometimes. See #166.
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

1 participant