タイムゾーンの設定忘れ
>夜泣き 編集の要約なし |
>夜泣き (タイムゾーンの設定忘れ) |
||
48行目: | 48行目: | ||
import warnings | import warnings | ||
import pytz | |||
import requests | import requests | ||
import bs4 | import bs4 | ||
336行目: | 337行目: | ||
date_str = tweet.find(class_='tweet-date').a['title'] | date_str = tweet.find(class_='tweet-date').a['title'] | ||
date = datetime.strptime(date_str, '%b %d, %Y · %I:%M %p UTC').replace(tzinfo=timezone.utc) | date = datetime.strptime(date_str, '%b %d, %Y · %I:%M %p UTC').replace(tzinfo=timezone.utc) | ||
tokyo = pytz.timezone('Asia/Tokyo') | |||
date = date.astimezone(tokyo) | |||
return date | return date | ||
472行目: | 475行目: | ||
soup: Final[BeautifulSoup] = BeautifulSoup(res.text, 'html.parser') ##beautifulsoupでレスポンス解析 | soup: Final[BeautifulSoup] = BeautifulSoup(res.text, 'html.parser') ##beautifulsoupでレスポンス解析 | ||
content: bs4.element.Tag = soup.find(id="CONTENT") ##archive.todayの魚拓一覧ページの中身だけ取得 | content: bs4.element.Tag = soup.find(id="CONTENT") ##archive.todayの魚拓一覧ページの中身だけ取得 | ||
if content.get_text()[:len(self.NO_ARCHIVE)] == self.NO_ARCHIVE: ##魚拓があるかないか判定 | if content is None or content.get_text()[:len(self.NO_ARCHIVE)] == self.NO_ARCHIVE: ##魚拓があるかないか判定 | ||
print(url + "の魚拓がない。これはいけない。") | print(url + "の魚拓がない。これはいけない。") | ||
else: | else: | ||
512行目: | 515行目: | ||
== 実行例 == | == 実行例 == | ||
20件での実行例。 | 20件での実行例。 | ||
=== | === 09月15日 === | ||
{|class="wikitable" style="text-align: left;" | {|class="wikitable" style="text-align: left;" | ||
!{{CallinShowLink|1=https://twitter.com/CallinShow/status/1570070806964862977|2=https://archive.ph/DUQA1}} | !{{CallinShowLink|1=https://twitter.com/CallinShow/status/1570070806964862977|2=https://archive.ph/DUQA1}} | ||
527行目: | 530行目: | ||
{{Archive|1=https://twitter.com/ota324/status/1570005982666960897|2=https://archive.ph/Gak9f|3=https://twitter.com/ota324/status/1570005982666960897}} | {{Archive|1=https://twitter.com/ota324/status/1570005982666960897|2=https://archive.ph/Gak9f|3=https://twitter.com/ota324/status/1570005982666960897}} | ||
|- | |- | ||
!{{CallinShowLink|1=https://twitter.com/CallinShow/status/1570207381098999808|2=https://archive.ph/DrAbJ}} | !{{CallinShowLink|1=https://twitter.com/CallinShow/status/1570207381098999808|2=https://archive.ph/DrAbJ}} | ||
|- | |- | ||
581行目: | 581行目: | ||
{{Archive|1=https://marshmallow-qa.com/apt/79c915f6-e889-4765-8dbb-cca0b6cea262|2=https://archive.ph/U55Qp|3=https://marshmallow-qa.com/apt/79c915f6-e889-4765-8dbb-cca0b6cea262}} | {{Archive|1=https://marshmallow-qa.com/apt/79c915f6-e889-4765-8dbb-cca0b6cea262|2=https://archive.ph/U55Qp|3=https://marshmallow-qa.com/apt/79c915f6-e889-4765-8dbb-cca0b6cea262}} | ||
|- | |- | ||
|} | |||
=== 09月16日 === | |||
{|class="wikitable" style="text-align: left;" | |||
!{{CallinShowLink|1=https://twitter.com/CallinShow/status/1570466085534838785|2=https://archive.ph/vUWjo}} | !{{CallinShowLink|1=https://twitter.com/CallinShow/status/1570466085534838785|2=https://archive.ph/vUWjo}} | ||
|- | |- | ||
612行目: | 615行目: | ||
|- | |- | ||
|} | |} | ||
=== | === 09月17日 === | ||
{|class="wikitable" style="text-align: left;" | {|class="wikitable" style="text-align: left;" | ||
!{{CallinShowLink|1=https://twitter.com/CallinShow/status/1570807392899829760|2=https://archive.ph/https://twitter.com/CallinShow/status/1570807392899829760}} | !{{CallinShowLink|1=https://twitter.com/CallinShow/status/1570807392899829760|2=https://archive.ph/https://twitter.com/CallinShow/status/1570807392899829760}} | ||
632行目: | 635行目: | ||
◎スノードーム | ◎スノードーム | ||
|- | |- | ||
!{{CallinShowLink|1=https://twitter.com/CallinShow/status/1570983261572329472|2=https://archive.ph/fIArg}} | !{{CallinShowLink|1=https://twitter.com/CallinShow/status/1570983261572329472|2=https://archive.ph/fIArg}} | ||
|- | |- |