LoginSignup
3
2

More than 5 years have passed since last update.

イングレスのミッションデーの日程を早目に知る方法

Posted at

はじめに

イングレスというゲームはアノマリーとかミッションデーとかに行こうとすると結構旅費がかかります。
旅費は早目に申し込んだほうが安く済むケースも多いですよね。
基本的には https://ingress.com/events を確認すればよいことですが、ちょっと自動化っぽくしたいと思いまして。。。

やってみたこと

Python3 + BeautifulSoup4 + Selenium + headless Chrome です。
ChromeDriverをインストールすることをお忘れなく。

ingress-md.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.chrome.options import Options
from bs4 import BeautifulSoup

options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
driver = webdriver.Chrome(chrome_options=options)

driver.get("https://ingress.com/events")
data = driver.page_source.encode('utf-8')

wait = WebDriverWait(driver, 1)
soup = BeautifulSoup(data,'lxml')

tables = soup.findAll("table")[2]

for table in tables:
  for tr in table.findAll('tr'):
     date = tr.find('td')
     a = tr.find('a')
     print("%s %s" % (date.text, a.attrs['href']))

上記スクリプトを実行すると、次のような内容が出力されます。

18-Nov-2017 http://events.ingress.com/MissionDay/kiel
18-Nov-2017 http://events.ingress.com/MissionDay/SantoDomingo
18-Nov-2017 http://events.ingress.com/MissionDay/Tulsa2017
19-Nov-2017 http://events.ingress.com/MissionDay/Dordrecht
25-Nov-2017 http://events.ingress.com/MissionDay/palermo
25-Nov-2017 http://events.ingress.com/MissionDay/Fuzhou
03-Dec-2017 https://splashthat.com/sites/view/missiondayhamamatsu.splashthat.com
03-Dec-2017 http://events.ingress.com/MissionDay/Perth
03-Dec-2017 http://events.ingress.com/MissionDay/TaipeiSehke
03-Dec-2017 http://events.ingress.com/MissionDay/Bruges
03-Dec-2017 http://events.ingress.com/MissionDay/Honolulu
03-Dec-2017 http://events.ingress.com/MissionDay/madrid
03-Dec-2017 http://events.ingress.com/MissionDay/SanFrancisco2017
03-Dec-2017 http://events.ingress.com/MissionDay/EXO5Tallinn
09-Dec-2017 http://events.ingress.com/MissionDay/Aveiro
09-Dec-2017 http://events.ingress.com/MissionDay/Montevideo
16-Dec-2017 http://events.ingress.com/MissionDay/BangkokSongsOfTheKing
16-Dec-2017 http://events.ingress.com/MissionDay/Chongqing
16-Dec-2017 http://events.ingress.com/MissionDay/NYC2017
13-Jan-2018 http://events.ingress.com/MissionDay/SantaCruzdelaSierra2018
13-Jan-2018 http://events.ingress.com/MissionDay/Guadalajara2018

ミッションデーではなくて、NL-1331の日程を知りたい場合は、

tables = soup.findAll("table")[1]

GORUCKの日程を知りたい場合は、

tables = soup.findAll("table")[3]

Operation Clear Fieldの日程を知りたい場合は、

tables = soup.findAll("table")[4]

コミュニティイベントの日程を知りたい場合は、

tables = soup.findAll("table")[5]

ファーストサタデーの日程を知りたい場合は、

tables = soup.findAll("table")[6]

としてください。

たとえば、cronで1日1回動かして、その結果をメールとかtelegramとかに流すとかするとよいかも!?

今後のこと

特にないです。

参考

Python3 + urllib + BeautifulSoupでネット上の情報を取得する

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2