feat: split to weather and gismeteo modules
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import datetime
|
||||
from typing import Dict, Iterable, List
|
||||
import re
|
||||
from typing import Dict, Iterable, List, Optional
|
||||
|
||||
import dateparser
|
||||
from bs4 import Tag
|
||||
@@ -9,6 +10,19 @@ from .core import BaseWidgetParser, RowParser
|
||||
ONE_DAY_PARSER = BaseWidgetParser(".widget.widget-oneday .widget-items")
|
||||
|
||||
|
||||
class LocationParser:
|
||||
PATTERN = re.compile('{"ru":{"city":{"name":"(.*?)"')
|
||||
|
||||
def parse_location(self, data: str) -> Optional[str]:
|
||||
match = self.PATTERN.search(data)
|
||||
if match:
|
||||
return match.group(1)
|
||||
return None
|
||||
|
||||
|
||||
LOCATION_PARSER = LocationParser()
|
||||
|
||||
|
||||
class DateParser(RowParser[datetime.datetime]):
|
||||
KEY = "date"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user