Browse Source

more tools

master
calexil 2 years ago
parent
commit
2b8ab4253a
3 changed files with 155 additions and 0 deletions
  1. 63
    0
      CODES.py
  2. 58
    0
      flair.py
  3. 34
    0
      setbot.py

+ 63
- 0
CODES.py View File

@@ -0,0 +1,63 @@
#!/usr/bin/python
# open the user flair page and put the cursor in the css class box(first one)
# open the EDIT wiki page with the set lists and prepare to run this script and immediately switch the cursopr to the end of the first line
import pyautogui
import os
# Set a counter to count the # of exceptions occur
counter = 0

# Start the while loop
while True:
try:
pyautogui.time.sleep(1)

pyautogui.keyDown('shift')
pyautogui.press('home')
pyautogui.keyUp('shift')

pyautogui.keyDown('ctrl')
pyautogui.press('c')
pyautogui.keyUp('ctrl')


pyautogui.keyDown('ctrl')
pyautogui.press('tab')
pyautogui.keyUp('ctrl')

pyautogui.keyDown('ctrl')
pyautogui.press('v')
pyautogui.keyUp('ctrl')

pyautogui.press('tab')
pyautogui.press('tab')
pyautogui.press('return')
pyautogui.time.sleep(1)
pyautogui.press('tab')
pyautogui.press('tab')
pyautogui.press('tab')
pyautogui.press('tab')
pyautogui.press('tab')
pyautogui.press('tab')
pyautogui.press('tab')
pyautogui.press('tab')
pyautogui.press('tab')

pyautogui.keyDown('ctrl')
pyautogui.press('tab')
pyautogui.keyUp('ctrl')

pyautogui.press('down')
pyautogui.press('down')
pyautogui.press('end')


# Exception handle when pyautogui can't locate the renew button on the screen
# or if it clicks away by mistake
# this section needs work and sometimes fails to function properly
except Exception:
print ("Exception thrown, calculating course of action")
pyautogui.press('pgdn')
counter += 1
print ("counter =" + str(counter))
if counter >= 3: counter = 0


+ 58
- 0
flair.py View File

@@ -0,0 +1,58 @@
#!/usr/bin/python
# open the user flair page and put the cursor in the css class box(first one)
# open the EDIT wiki page with the set lists and prepare to run this script and immediately switch the cursopr to the end of the first line
import pyautogui
import os
# Set a counter to count the # of exceptions occur
counter = 0

# Start the while loop
while True:
try:
pyautogui.time.sleep(1)

pyautogui.keyDown('shift')
pyautogui.press('home')
pyautogui.keyUp('shift')

pyautogui.keyDown('ctrl')
pyautogui.press('c')
pyautogui.keyUp('ctrl')


pyautogui.keyDown('ctrl')
pyautogui.press('tab')
pyautogui.keyUp('ctrl')

pyautogui.keyDown('ctrl')
pyautogui.press('v')
pyautogui.keyUp('ctrl')

pyautogui.press('tab')
pyautogui.press('return')
pyautogui.time.sleep(2)
pyautogui.press('tab')
pyautogui.press('space')
pyautogui.press('tab')
pyautogui.press('tab')


pyautogui.keyDown('ctrl')
pyautogui.press('tab')
pyautogui.keyUp('ctrl')

pyautogui.press('down')
pyautogui.press('down')
pyautogui.press('end')


# Exception handle when pyautogui can't locate the renew button on the screen
# or if it clicks away by mistake
# this section needs work and sometimes fails to function properly
except Exception:
print ("Exception thrown, calculating course of action")
pyautogui.press('pgdn')
counter += 1
print ("counter =" + str(counter))
if counter >= 3: counter = 0


+ 34
- 0
setbot.py View File

@@ -0,0 +1,34 @@
#Welcome to setbot, a tool to parse mtg set symbols for user flair on reddit
from pyquery import PyQuery as pq
from lxml import html
import requests
import praw
import urllib

URL = "https://magic.wizards.com/en/products/card-set-archive"

def main():

session_requests = requests.session()

# Scrape rank data from navbar span
result = session_requests.get(URL, headers = dict(referer = URL))
tree = html.fromstring(result.content)
set_list = tree.xpath('//*[string-length(@id) = 3]/div/ul/li[2]/a/span[2]')

# Dunno the syntax for the tool you're using
# But internally all HTML elements are HTML Nodes
# So basically
# groups = getAllNodes('.card-set-archive-table')
# for group in groups
# sets = group.getAllNodes('li.modern-format')
# for set in sets
# imageNode = set.getAllNodes('.icon img')
# imageUrl = imageNode.src
# downloadImage(imageUrl)

print "%s" % set_list


if __name__ == '__main__':
main()

Loading…
Cancel
Save