support pst timezone
This commit is contained in:
parent
a632b75b8f
commit
02549c2c3b
1 changed files with 13 additions and 12 deletions
|
@ -89,15 +89,13 @@ except (wa.LoginIncorrect, FileNotFoundError) as exp:
|
||||||
# CRAWL
|
# CRAWL
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone, timedelta
|
||||||
import pytz
|
|
||||||
import re
|
import re
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
import requests
|
import requests
|
||||||
from hashlib import sha3_256
|
from hashlib import sha3_256
|
||||||
import pg8000
|
import pg8000
|
||||||
|
|
||||||
pdt = pytz.timezone("Us/Pacific")
|
|
||||||
db = pg8000.connect(
|
db = pg8000.connect(
|
||||||
database=environ['DB_NAME'],
|
database=environ['DB_NAME'],
|
||||||
user=environ['DB_USER'],
|
user=environ['DB_USER'],
|
||||||
|
@ -118,7 +116,10 @@ def parse_trs(trs):
|
||||||
from_name = tds[0].text
|
from_name = tds[0].text
|
||||||
to_url = tds[1].find('a')['href']
|
to_url = tds[1].find('a')['href']
|
||||||
to_name = tds[1].text
|
to_name = tds[1].text
|
||||||
date = datetime.strptime(tds[2].text, '%b %d, %Y @ %I:%M%p PDT').replace(tzinfo=pdt)
|
timestamp_string, timezone_string = tds[2].text.rsplit(None, 1)
|
||||||
|
offsets = {'PST': -8, 'PDT': -7}
|
||||||
|
timezone_object = timezone(timedelta(hours=offsets[timezone_string]), 'UTC')
|
||||||
|
date = datetime.strptime(timestamp_string, '%b %d, %Y @ %I:%M%p').replace(tzinfo=timezone_object)
|
||||||
message = tds[3].text
|
message = tds[3].text
|
||||||
checksum = sha3_256(
|
checksum = sha3_256(
|
||||||
(from_url + to_url + str(date.timestamp()) + message).encode()
|
(from_url + to_url + str(date.timestamp()) + message).encode()
|
||||||
|
|
Loading…
Reference in a new issue