Created
September 8, 2020 13:52
-
-
Save Scrxtchy/800f299734cea9950d2e9203f14d4a11 to your computer and use it in GitHub Desktop.
Scrape Ishgard Restoration for Progress Alerts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup as bs4 | |
import requests | |
import pickle | |
#checkpoints = {"Tonberry":[], "Cactuar":[]} ## run these at some point to init datastorage | |
#pickle.dump(checkpoints, open("xiv.prog", "wb")) ## imaging spending time automating setup instead of gaming | |
x = requests.get('https://eu.finalfantasyxiv.com/lodestone/ishgardian_restoration/builders_progress_report') | |
soup = bs4(x.text, 'html.parser') | |
worlds = ["Tonberry", "Cactuar"] | |
checkpoints = pickle.load(open("xiv.prog", "rb")) | |
def sendMessage(message): | |
# Write your own notification processor | |
return | |
def getWorld(name): | |
return soup.find_all("span", attrs={"class":"world_name"}, string=name)[0].parent | |
def getPhase(node): | |
return node.find("p").text | |
def getProg(node): | |
return float(node.find("div", attrs={"class":"bar"}).span["style"][:-1][7:]) | |
for world in worlds: | |
worldNode = getWorld(world) | |
if getPhase(worldNode) not in checkpoints[world]: | |
prog = getProg(worldNode) | |
if prog > 90: | |
checkpoints[world].append(phase) | |
sendMessage("{} is at {}%".format(world, prog)) | |
pickle.dump(checkpoints, open("xiv.prog", "wb")) | |
from sys import exit | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment