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

Update pyproject.toml + fake-useragent fixes #292

Merged
merged 6 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion camply/providers/base_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self):
"""
Initialize with a session
"""
_user_agent = UserAgent(use_external_data=False, browsers=["chrome"]).chrome
_user_agent = UserAgent(browsers=["chrome"]).random
self.session = requests.Session()
self.headers = {"User-Agent": _user_agent}
self.session.headers = self.headers
Expand Down
4 changes: 1 addition & 3 deletions camply/providers/going_to_camp/going_to_camp_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,7 @@ def _api_request(
url = None
if endpoint:
url = endpoint.format(hostname)
user_agent = {
"User-Agent": UserAgent(use_external_data=False, browsers=["chrome"]).chrome
}
user_agent = {"User-Agent": UserAgent(browsers=["chrome"]).random}
response = requests.get(url=url, headers=user_agent, params=params, timeout=30)
if response.ok is False:
error_message = f"Receiving bad data from GoingToCamp API: status_code: {response.status_code}: {response.text}"
Expand Down
6 changes: 2 additions & 4 deletions camply/providers/recreation_dot_gov/recdotgov_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, api_key: Optional[str] = None):
"accept": "application/json",
"apikey": _api_key,
}
_user_agent = UserAgent(use_external_data=False, browsers=["chrome"]).chrome
_user_agent = UserAgent(browsers=["chrome"]).random
self._user_agent = {"User-Agent": _user_agent}

@property
Expand Down Expand Up @@ -579,9 +579,7 @@ def make_recdotgov_request(
requests.Response
"""
# BUILD THE HEADERS EXPECTED FROM THE API
user_agent = {
"User-Agent": UserAgent(use_external_data=False, browsers=["chrome"]).chrome
}
user_agent = {"User-Agent": UserAgent(browsers=["chrome"]).random}
headers = STANDARD_HEADERS.copy()
headers.update(user_agent)
headers.update(RecreationBookingConfig.API_REFERRERS)
Expand Down
3 changes: 3 additions & 0 deletions camply/providers/usedirect/usedirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Any, Dict, List, Optional, Union

import ratelimit
from fake_useragent import UserAgent
from pydantic import ValidationError

from camply.config import FileConfig
Expand Down Expand Up @@ -322,6 +323,8 @@ def get_campsites_response(
key: value for key, value in data.items() if value not in [None, [], ""]
}
url = f"{self.base_url}/{self.rdr_path}/{UseDirectConfig.AVAILABILITY_ENDPOINT}"
random_ua = UserAgent(browsers=["chrome"]).random
self.json_headers["User-Agent"] = random_ua
response = self.make_http_request_retry(
url=url,
method="POST",
Expand Down
4 changes: 1 addition & 3 deletions camply/providers/xanterra/yellowstone_lodging.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ def _try_retry_get_data(endpoint: str, params: Optional[dict] = None) -> dict:
dict
"""
yellowstone_headers = {}
user_agent = {
"User-Agent": UserAgent(use_external_data=False, browsers=["chrome"]).chrome
}
user_agent = {"User-Agent": UserAgent(browsers=["chrome"]).random}
yellowstone_headers.update(user_agent)
yellowstone_headers.update(STANDARD_HEADERS)
yellowstone_headers.update(YellowstoneConfig.API_REFERRERS)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
]
dependencies = [
"click~=8.1.3",
"fake-useragent~=1.1.3",
"fake-useragent~=1.4.0",
"pandas>=2,<3",
"pydantic~=1.10.13",
"python-dotenv~=1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by hatch-pip-compile with Python 3.11
#
# - click~=8.1.3
# - fake-useragent~=1.1.3
# - fake-useragent~=1.4.0
# - pandas<3,>=2
# - pydantic~=1.10.13
# - python-dotenv~=1.0.0
Expand Down Expand Up @@ -32,7 +32,7 @@ click==8.1.7
# apprise
# rich-click
# trogon
fake-useragent==1.1.3
fake-useragent==1.4.0
# via hatch.envs.default
idna==3.6
# via requests
Expand Down
4 changes: 2 additions & 2 deletions requirements/requirements-all.py3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - pytest-xdist~=3.2.1
# - freezegun~=1.2.1
# - click~=8.1.3
# - fake-useragent~=1.1.3
# - fake-useragent~=1.4.0
# - pandas<3,>=2
# - pydantic~=1.10.13
# - python-dotenv~=1.0.0
Expand Down Expand Up @@ -46,7 +46,7 @@ exceptiongroup==1.2.0
# via pytest
execnet==2.0.2
# via pytest-xdist
fake-useragent==1.1.3
fake-useragent==1.4.0
# via hatch.envs.all.py3.10
freezegun==1.2.2
# via hatch.envs.all.py3.10
Expand Down
4 changes: 2 additions & 2 deletions requirements/requirements-all.py3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - pytest-xdist~=3.2.1
# - freezegun~=1.2.1
# - click~=8.1.3
# - fake-useragent~=1.1.3
# - fake-useragent~=1.4.0
# - pandas<3,>=2
# - pydantic~=1.10.13
# - python-dotenv~=1.0.0
Expand Down Expand Up @@ -44,7 +44,7 @@ coverage==7.4.0
# pytest-cov
execnet==2.0.2
# via pytest-xdist
fake-useragent==1.1.3
fake-useragent==1.4.0
# via hatch.envs.all.py3.11
freezegun==1.2.2
# via hatch.envs.all.py3.11
Expand Down
4 changes: 2 additions & 2 deletions requirements/requirements-all.py3.12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - pytest-xdist~=3.2.1
# - freezegun~=1.2.1
# - click~=8.1.3
# - fake-useragent~=1.1.3
# - fake-useragent~=1.4.0
# - pandas<3,>=2
# - pydantic~=1.10.13
# - python-dotenv~=1.0.0
Expand Down Expand Up @@ -44,7 +44,7 @@ coverage==7.4.0
# pytest-cov
execnet==2.0.2
# via pytest-xdist
fake-useragent==1.1.3
fake-useragent==1.4.0
# via hatch.envs.all.py3.12
freezegun==1.2.2
# via hatch.envs.all.py3.12
Expand Down
4 changes: 2 additions & 2 deletions requirements/requirements-all.py3.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - pytest-xdist~=3.2.1
# - freezegun~=1.2.1
# - click~=8.1.3
# - fake-useragent~=1.1.3
# - fake-useragent~=1.4.0
# - pandas<3,>=2
# - pydantic~=1.10.13
# - python-dotenv~=1.0.0
Expand Down Expand Up @@ -46,7 +46,7 @@ exceptiongroup==1.2.0
# via pytest
execnet==2.0.2
# via pytest-xdist
fake-useragent==1.1.3
fake-useragent==1.4.0
# via hatch.envs.all.py3.8
freezegun==1.2.2
# via hatch.envs.all.py3.8
Expand Down
8 changes: 3 additions & 5 deletions requirements/requirements-all.py3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - pytest-xdist~=3.2.1
# - freezegun~=1.2.1
# - click~=8.1.3
# - fake-useragent~=1.1.3
# - fake-useragent~=1.4.0
# - pandas<3,>=2
# - pydantic~=1.10.13
# - python-dotenv~=1.0.0
Expand Down Expand Up @@ -39,14 +39,12 @@ click==8.1.7
# rich-click
# trogon
coverage==7.4.0
# via
# coverage
# pytest-cov
# via pytest-cov
exceptiongroup==1.2.0
# via pytest
execnet==2.0.2
# via pytest-xdist
fake-useragent==1.1.3
fake-useragent==1.4.0
# via hatch.envs.all.py3.9
freezegun==1.2.2
# via hatch.envs.all.py3.9
Expand Down
6 changes: 3 additions & 3 deletions requirements/requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# This file is autogenerated by hatch-pip-compile with Python 3.11
#
# [constraints] requirements.txt (SHA256: 7d2ce7d5ed6d5060713188a3a42ce8fdfb3aa0da2ebcb6a000c552ab9fb0cf33)
# [constraints] requirements.txt (SHA256: 2a92e1c6e109ef4c9ce314b9a60b303169d2ddf6cb3b4c4c9df4288cec4ac2ef)
#
# - markdown-callouts
# - markdown-exec
Expand All @@ -16,7 +16,7 @@
# - mkdocstrings-python
# - pymdown-extensions
# - click~=8.1.3
# - fake-useragent~=1.1.3
# - fake-useragent~=1.4.0
# - pandas<3,>=2
# - pydantic~=1.10.13
# - python-dotenv~=1.0.0
Expand Down Expand Up @@ -51,7 +51,7 @@ colorama==0.4.6
# via
# griffe
# mkdocs-material
fake-useragent==1.1.3
fake-useragent==1.4.0
# via
# -c requirements.txt
# hatch.envs.docs
Expand Down
6 changes: 3 additions & 3 deletions requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# This file is autogenerated by hatch-pip-compile with Python 3.11
#
# [constraints] requirements.txt (SHA256: 7d2ce7d5ed6d5060713188a3a42ce8fdfb3aa0da2ebcb6a000c552ab9fb0cf33)
# [constraints] requirements.txt (SHA256: 2a92e1c6e109ef4c9ce314b9a60b303169d2ddf6cb3b4c4c9df4288cec4ac2ef)
#
# - pytest~=7.3.1
# - pytest-cov~=4.0.0
Expand All @@ -10,7 +10,7 @@
# - pytest-xdist~=3.2.1
# - freezegun~=1.2.1
# - click~=8.1.3
# - fake-useragent~=1.1.3
# - fake-useragent~=1.4.0
# - pandas<3,>=2
# - pydantic~=1.10.13
# - python-dotenv~=1.0.0
Expand Down Expand Up @@ -52,7 +52,7 @@ coverage==7.2.7
# pytest-cov
execnet==1.9.0
# via pytest-xdist
fake-useragent==1.1.3
fake-useragent==1.4.0
# via
# -c requirements.txt
# hatch.envs.test
Expand Down
Loading