Skip to content

Instantly share code, notes, and snippets.

@Scrxtchy
Created September 8, 2020 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Scrxtchy/800f299734cea9950d2e9203f14d4a11 to your computer and use it in GitHub Desktop.
Save Scrxtchy/800f299734cea9950d2e9203f14d4a11 to your computer and use it in GitHub Desktop.
Scrape Ishgard Restoration for Progress Alerts
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