fixed tuh-tracker
This commit is contained in:
parent
9a7b09c159
commit
bc93bb48cb
@ -43,7 +43,8 @@ def fetch_latest_log() -> datetime | None:
|
||||
|
||||
def parse_last_seen(text: str) -> datetime | None:
|
||||
now = datetime.now()
|
||||
if "Visto por última vez" in text:
|
||||
print(f"processing the following text: {text}")
|
||||
if "Visto por última vez" or "ltimos vistos" in text:
|
||||
days_match = re.search(r"(\d+) día", text)
|
||||
hours_match = re.search(r"(\d+) horas", text)
|
||||
minutes_match = re.search(r"(\d+) minutos", text)
|
||||
@ -64,20 +65,24 @@ def parse_last_seen(text: str) -> datetime | None:
|
||||
def scrape_and_log(url: str) -> None:
|
||||
response = requests.get(url)
|
||||
if response.status_code != 200:
|
||||
print(f"Error {response.status_code}")
|
||||
return
|
||||
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
details_row = soup.find("div", class_="details-row")
|
||||
if not details_row:
|
||||
print("No details-row found, code changed")
|
||||
return
|
||||
|
||||
offline_div = details_row.find("div", class_="offline")
|
||||
if not offline_div:
|
||||
print("No offline class found, code changed")
|
||||
return
|
||||
|
||||
last_seen_text = offline_div.text.strip()
|
||||
last_seen_time = parse_last_seen(last_seen_text)
|
||||
if not last_seen_time:
|
||||
print("No last seen time could be extracted")
|
||||
return
|
||||
|
||||
latest_log = fetch_latest_log()
|
||||
@ -97,6 +102,7 @@ def scrape_and_log(url: str) -> None:
|
||||
def main():
|
||||
url = "https://es.xhamsterporno.mx/users/johnneal911"
|
||||
setup_database()
|
||||
print("chichis")
|
||||
scrape_and_log(url)
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user