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:
|
def parse_last_seen(text: str) -> datetime | None:
|
||||||
now = datetime.now()
|
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)
|
days_match = re.search(r"(\d+) día", text)
|
||||||
hours_match = re.search(r"(\d+) horas", text)
|
hours_match = re.search(r"(\d+) horas", text)
|
||||||
minutes_match = re.search(r"(\d+) minutos", 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:
|
def scrape_and_log(url: str) -> None:
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
|
print(f"Error {response.status_code}")
|
||||||
return
|
return
|
||||||
|
|
||||||
soup = BeautifulSoup(response.text, "html.parser")
|
soup = BeautifulSoup(response.text, "html.parser")
|
||||||
details_row = soup.find("div", class_="details-row")
|
details_row = soup.find("div", class_="details-row")
|
||||||
if not details_row:
|
if not details_row:
|
||||||
|
print("No details-row found, code changed")
|
||||||
return
|
return
|
||||||
|
|
||||||
offline_div = details_row.find("div", class_="offline")
|
offline_div = details_row.find("div", class_="offline")
|
||||||
if not offline_div:
|
if not offline_div:
|
||||||
|
print("No offline class found, code changed")
|
||||||
return
|
return
|
||||||
|
|
||||||
last_seen_text = offline_div.text.strip()
|
last_seen_text = offline_div.text.strip()
|
||||||
last_seen_time = parse_last_seen(last_seen_text)
|
last_seen_time = parse_last_seen(last_seen_text)
|
||||||
if not last_seen_time:
|
if not last_seen_time:
|
||||||
|
print("No last seen time could be extracted")
|
||||||
return
|
return
|
||||||
|
|
||||||
latest_log = fetch_latest_log()
|
latest_log = fetch_latest_log()
|
||||||
@ -97,6 +102,7 @@ def scrape_and_log(url: str) -> None:
|
|||||||
def main():
|
def main():
|
||||||
url = "https://es.xhamsterporno.mx/users/johnneal911"
|
url = "https://es.xhamsterporno.mx/users/johnneal911"
|
||||||
setup_database()
|
setup_database()
|
||||||
|
print("chichis")
|
||||||
scrape_and_log(url)
|
scrape_and_log(url)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user