Skip to content

Instantly share code, notes, and snippets.

@sharl
Created August 28, 2023 08:40
Show Gist options
  • Save sharl/d8dea92def64eaf0a505e120ece20f78 to your computer and use it in GitHub Desktop.
Save sharl/d8dea92def64eaf0a505e120ece20f78 to your computer and use it in GitHub Desktop.
つよさ予報からアストルティア防衛軍の全兵団襲撃を抽出
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# つよさ予報からアストルティア防衛軍の全兵団襲撃を抽出
import requests
from bs4 import BeautifulSoup
base_url = 'https://hiroba.dqx.jp/sc/tokoyami/'
r = requests.get(base_url, timeout=10)
if r and r.status_code == 200:
soup = BeautifulSoup(r.content, 'html.parser')
# 同じクラスでメタルーキーもあるので先頭だけ
tables = soup.find_all('table', class_='tokoyami-raid')[0]
trs = tables.find_all('tr')
attacks = []
for tr in trs:
tds = tr.find_all('td')
# th のときは td がないのでスキップ
if len(tds) == 0:
continue
_time = tds[0].contents[0].strip().split('\xa0')[0]
_ico = tds[1].contents[1]
# 全兵団アイコン
if '/raid/ico/19.png' in str(_ico) and _time:
attacks.append(_time)
print('本日のアストルティア防衛軍 全兵団は', ' '.join(attacks), 'です')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment