Skip to content

Commit

Permalink
Merge pull request #38 from rarDevelopment/master
Browse files Browse the repository at this point in the history
another fix for the url changing
  • Loading branch information
ScrappyCocco authored Dec 29, 2024
2 parents 6be69cd + b9ca77c commit a746c98
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions howlongtobeatpy/howlongtobeatpy/HTMLRequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SearchModifiers(Enum):
class HTMLRequests:
BASE_URL = 'https://howlongtobeat.com/'
REFERER_HEADER = BASE_URL
SEARCH_URL = BASE_URL + "api/find"
SEARCH_URL = BASE_URL + "api/lookup"
GAME_URL = BASE_URL + "game"

@staticmethod
Expand Down Expand Up @@ -116,7 +116,7 @@ def send_web_request(game_name: str, search_modifiers: SearchModifiers = SearchM
if api_key_result is None:
api_key_result = HTMLRequests.send_website_request_getcode(True)
# Make the request
# The main method currently is the call to api/find/key
# The main method currently is the call to api/lookup/key
search_url_with_key = HTMLRequests.SEARCH_URL + "/" + api_key_result
payload = HTMLRequests.get_search_request_data(game_name, search_modifiers, page, None)
resp = requests.post(search_url_with_key, headers=headers, data=payload, timeout=60)
Expand Down Expand Up @@ -145,7 +145,7 @@ async def send_async_web_request(game_name: str, search_modifiers: SearchModifie
if api_key_result is None:
api_key_result = await HTMLRequests.async_send_website_request_getcode(True)
# Make the request
# The main method currently is the call to api/find/key
# The main method currently is the call to api/lookup/key
search_url_with_key = HTMLRequests.SEARCH_URL + "/" + api_key_result
payload = HTMLRequests.get_search_request_data(game_name, search_modifiers, page, None)
async with aiohttp.ClientSession() as session:
Expand Down Expand Up @@ -253,8 +253,8 @@ def extract_api_from_script(script_content: str):
if matches:
key = ''.join(matches)
return key
# Test 2 - The API Key is in format fetch("/api/find/".concat("X").concat("Y")...
concat_api_key_pattern = r'\/api\/find\/"(?:\.concat\("[^"]*"\))*'
# Test 2 - The API Key is in format fetch("/api/lookup/".concat("X").concat("Y")...
concat_api_key_pattern = r'\/api\/lookup\/"(?:\.concat\("[^"]*"\))*'
matches = re.findall(concat_api_key_pattern, script_content)
if matches:
matches = str(matches).split('.concat')
Expand All @@ -267,7 +267,7 @@ def extract_api_from_script(script_content: str):
@staticmethod
def send_website_request_getcode(parse_all_scripts: bool):
"""
Function that send a request to howlongtobeat to scrape the /api/find key
Function that send a request to howlongtobeat to scrape the /api/lookup key
@return: The string key to use
"""
# Make the post request and return the result if is valid
Expand All @@ -294,7 +294,7 @@ def send_website_request_getcode(parse_all_scripts: bool):
@staticmethod
async def async_send_website_request_getcode(parse_all_scripts: bool):
"""
Function that send a request to howlongtobeat to scrape the /api/find key
Function that send a request to howlongtobeat to scrape the /api/lookup key
@return: The string key to use
"""
# Make the post request and return the result if is valid
Expand Down

0 comments on commit a746c98

Please sign in to comment.