Compare commits
No commits in common. "c6fd5bc5cced2ddd7be06479b20548239304d760" and "090b854f666619807d0a6aeaacab652fe2cfc512" have entirely different histories.
c6fd5bc5cc
...
090b854f66
|
@ -1 +1 @@
|
||||||
__version__ = '0.1.41'
|
__version__ = '0.1.40'
|
||||||
|
|
|
@ -2,10 +2,13 @@ import dataclasses
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import secrets
|
||||||
|
|
||||||
import bs4
|
import bs4
|
||||||
|
|
||||||
from ..data import DeduplicateMode, Scraper
|
import personal_data.html_util
|
||||||
from .. import secrets, parse_util, html_util
|
import personal_data.parse_util
|
||||||
|
from personal_data.data import DeduplicateMode, Scraper
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -34,11 +37,11 @@ class LodestoneAchievementScraper(Scraper):
|
||||||
response = self.session.get(url)
|
response = self.session.get(url)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
NOW = parse_util.parse_response_datetime(response)
|
NOW = personal_data.parse_util.parse_response_datetime(response)
|
||||||
|
|
||||||
# Parse data
|
# Parse data
|
||||||
soup = bs4.BeautifulSoup(response.content, 'lxml')
|
soup = bs4.BeautifulSoup(response.content, 'lxml')
|
||||||
soup = html_util.normalize_soup_slightly(
|
soup = personal_data.html_util.normalize_soup_slightly(
|
||||||
soup,
|
soup,
|
||||||
classes=False,
|
classes=False,
|
||||||
scripts=False,
|
scripts=False,
|
||||||
|
@ -51,7 +54,7 @@ class LodestoneAchievementScraper(Scraper):
|
||||||
time_acquired,
|
time_acquired,
|
||||||
).group(1)
|
).group(1)
|
||||||
time_acquired = int(time_acquired)
|
time_acquired = int(time_acquired)
|
||||||
time_acquired = datetime.datetime.fromtimestamp(time_acquired,tz=datetime.UTC)
|
time_acquired = datetime.datetime.fromtimestamp(time_acquired)
|
||||||
trophy_desc = (
|
trophy_desc = (
|
||||||
entry.select_one('.entry__activity__txt').get_text().strip()
|
entry.select_one('.entry__activity__txt').get_text().strip()
|
||||||
)
|
)
|
||||||
|
|
|
@ -36,16 +36,10 @@ def parse_response_datetime(response) -> datetime.datetime:
|
||||||
).replace(tzinfo=datetime.UTC)
|
).replace(tzinfo=datetime.UTC)
|
||||||
|
|
||||||
|
|
||||||
LOCAL_TIMEZONE = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo
|
|
||||||
|
|
||||||
|
|
||||||
def parse_time(text: str) -> datetime.datetime:
|
def parse_time(text: str) -> datetime.datetime:
|
||||||
text = text.replace('\n', ' ')
|
text = text.replace('\n', ' ')
|
||||||
text = text.strip()
|
text = text.strip()
|
||||||
time = datetime.datetime.strptime(text, '%d %b %Y %I:%M:%S %p')
|
return datetime.datetime.strptime(text, '%d %b %Y %I:%M:%S %p')
|
||||||
time = time.replace(tzinfo=LOCAL_TIMEZONE)
|
|
||||||
assert time.tzinfo is not None, time
|
|
||||||
return time
|
|
||||||
|
|
||||||
|
|
||||||
def parse_date(text: str) -> datetime.date:
|
def parse_date(text: str) -> datetime.date:
|
||||||
|
|
|
@ -62,8 +62,6 @@ def csv_str_to_value(
|
||||||
def csv_safe_value(v: object) -> str:
|
def csv_safe_value(v: object) -> str:
|
||||||
if isinstance(v, urllib.parse.ParseResult):
|
if isinstance(v, urllib.parse.ParseResult):
|
||||||
return v.geturl()
|
return v.geturl()
|
||||||
if isinstance(v, datetime.datetime):
|
|
||||||
assert v.tzinfo is not None, v
|
|
||||||
return str(v)
|
return str(v)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user