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

ipapi location rate limited #196

Open
2 tasks done
Guido30 opened this issue Aug 31, 2024 · 3 comments
Open
2 tasks done

ipapi location rate limited #196

Guido30 opened this issue Aug 31, 2024 · 3 comments
Labels
bug Something isn't working stale

Comments

@Guido30
Copy link

Guido30 commented Aug 31, 2024

Before submitting a bug report...

  • This bug wasn't already reported.
    (I have checked every bug report on GitHub)

  • I've cleared the sessions folder.

Branch

master

Commit

c9bc044

Describe the bug

When running the script multiple times a day (because of crashes) eventually the ipapi library will rate limit you for the rest of that day

Copy and paste your error

2024-08-31 11:52:32,433 [INFO] [BING] Finished Desktop Edge Bing searches !
2024-08-31 11:53:11,378 [WARNING] Returning default
Traceback (most recent call last):
File "C:\repos\MS-Rewards-Farmer\src\browser.py", line 207, in getCCodeLang
nfo = ipapi.location()
^^^^^^^^^^^^^^^^
File "C:\repos\MS-Rewards-Farmer.venv\Lib\site-packages\ipapi\ipapi.py", line 87, in location
raise RateLimited(data)
ipapi.exceptions.RateLimited: {'error': True, 'reason': 'RateLimited', 'message': 'Visit https://ipapi.co/ratelimited/ for details'}

Screenshots

None

Value of dashboard variable

None

@Guido30 Guido30 added the bug Something isn't working label Aug 31, 2024
@cal4
Copy link
Collaborator

cal4 commented Aug 31, 2024

Could cache the result of this call to disk, or refactor so that it isn't called as often per run (preferable in case bot moves between geographic locations between runs)

Could also switch to some other library that doesn't rate limit as much

@badcaf3
Copy link

badcaf3 commented Sep 1, 2024

i tried ipinfo it works fine. here is the code i generated from chatgpt 😭

@staticmethod
def getCCodeLang(lang: str, geo: str) -> Tuple:
if lang is None or geo is None:
try:
response = requests.get("https://ipinfo.io/json")
nfo = response.json()
print(nfo)
except requests.RequestException:
logging.warning(
"Returning default due to API request failure", exc_info=True
)
return "vi", "VN"
if isinstance(nfo, dict):
if lang is None:
lang = nfo.get("languages", "vi").split(",")[0].split("-")[0]
if geo is None:
geo = nfo.get("country", "VN")
return lang, geo

Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants