From 2a7dd3e69fb434c1a9a6807a7b1df01291e5cb00 Mon Sep 17 00:00:00 2001 From: 0ceanSlim Date: Mon, 13 Nov 2023 20:51:19 -0500 Subject: [PATCH] added script for pulling Card name and set number from lorcanawiz --- saveList.py | 63 +++++++++++++++ setlist1.csv | 217 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 saveList.py create mode 100644 setlist1.csv diff --git a/saveList.py b/saveList.py new file mode 100644 index 0000000..73b5f56 --- /dev/null +++ b/saveList.py @@ -0,0 +1,63 @@ +from selenium import webdriver +import csv +import requests +import os +import zipfile +from io import BytesIO +from selenium.webdriver.common.by import By + + +def scrape_and_save_data(url, output_csv_path): + # Define the directory path and URLs for Chrome and Chromedriver + chrome_directory = 'c:/tmp/chrome' + chrome_exe_path = 'c:/tmp/chrome/chrome-win64/chrome.exe' # Modify this path as needed + chrome_url = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/117.0.5938.92/win64/chrome-win64.zip' + + # Check if the Chrome directory exists, and if not, create it + if not os.path.exists(chrome_directory): + os.makedirs(chrome_directory) + + # Check if Chrome.exe and Chromedriver.exe exist in the directory + if not os.path.exists(os.path.join(chrome_exe_path)): + # Download and extract Chrome + chrome_response = requests.get(chrome_url) + with zipfile.ZipFile(BytesIO(chrome_response.content), 'r') as zip_ref: + zip_ref.extractall(chrome_directory) + + # Set up Chrome options + chrome_options = webdriver.ChromeOptions() + chrome_options.binary_location = chrome_exe_path + + # Set up the Selenium WebDriver + driver = webdriver.Chrome(options=chrome_options) + + # Navigate to the webpage + driver.get(url) + + # Find all elements with the specified class names + name_elements = driver.find_elements(By.CSS_SELECTOR, '.card-list-name-txt') + number_elements = driver.find_elements(By.CSS_SELECTOR, '.card-list-num') + + + # Extract data and store it in a list of dictionaries + data = [{'Name': name.text, 'Number': number.text} for name, number in zip(name_elements, number_elements)] + + # Save data to CSV file + with open(output_csv_path, 'w', newline='', encoding='utf-8') as csv_file: + fieldnames = ['Name', 'Number'] + writer = csv.DictWriter(csv_file, fieldnames=fieldnames) + writer.writeheader() + writer.writerows(data) + + + + # Close the browser + driver.quit() + +if __name__ == "__main__": + # Replace these values with your actual URL, ChromeDriver path, and output CSV path + webpage_url = 'https://www.lorcanawiz.com/cards/the-first-chapter' + output_csv_path = 'setlist1.csv' + + # Call the function to scrape and save data + scrape_and_save_data(webpage_url, output_csv_path) diff --git a/setlist1.csv b/setlist1.csv new file mode 100644 index 0000000..d38e323 --- /dev/null +++ b/setlist1.csv @@ -0,0 +1,217 @@ +Name,Number +Ariel,1 +Ariel,2 +Cinderella,3 +Goofy,4 +Hades,5 +Hades,6 +HeiHei,7 +LeFou,8 +Lilo,9 +Maximus,10 +Maximus,11 +Mickey Mouse,12 +Minnie Mouse,13 +Moana,14 +Mr. Smee,15 +Prince Phillip,16 +Pumbaa,17 +Rapunzel,18 +Sebastian,19 +Simba,20 +Stitch,21 +Stitch,22 +Stitch,23 +Timon,24 +Be Our Guest,25 +Control Your Temper!,26 +Hakuna Matata,27 +Healing Glow,28 +Just in Time,29 +Part of Your World,30 +You Have Forgotten Me,31 +Dinglehopper,32 +Lantern,33 +Ursula’s Shell Necklace,34 +Anna,35 +Archimedes,36 +Dr. Facilier,37 +Dr. Facilier,38 +Dr. Facilier,39 +Elsa,40 +Elsa,41 +Elsa,42 +Flotsam,43 +Jafar,44 +Jafar,45 +Jetsam,46 +Magic Broom,47 +Maleficent,48 +Maleficent,49 +Marshmallow,50 +Mickey Mouse,51 +Olaf,52 +Pascal,53 +Rafiki,54 +Sven,55 +The Queen,56 +The Wardrobe,57 +Tinker Bell,58 +Ursula,59 +Yzma,60 +Zeus,61 +Befuddle,62 +Freeze,63 +Friends on the Other Side,64 +Reflection,65 +Magic Mirror,66 +Ursula’s Cauldron,67 +White Rabbit’s Pocket Watch,68 +Aladdin,69 +Beast,70 +Cheshire Cat,71 +Cruella De Vil,72 +Duke of Weselton,73 +Flynn Rider,74 +Genie,75 +Genie,76 +Genie,77 +Hans,78 +Horace,79 +Iago,80 +Jasper,81 +John Silver,82 +Jumba Jookiba,83 +Kuzco,84 +Lady Tremaine,85 +Mad Hatter,86 +Megara,87 +Mickey Mouse,88 +Mickey Mouse,89 +Mother Gothel,90 +Peter Pan,91 +Tamatoa,92 +Tinker Bell,93 +Do It Again!,94 +Mother Knows Best,95 +Stampede,96 +Steal from the Rich,97 +Sudden Chill,98 +The Beast is Mine!,99 +Vicious Betrayal,100 +Dr. Facilier’s Cards,101 +Stolen Scimitar,102 +Abu,103 +Aladdin,104 +Aladdin,105 +Captain,106 +Captain Hook,107 +Donald Duck,108 +Elsa,109 +Gaston,110 +Goofy,111 +LeFou,112 +Maleficent,113 +Maui,114 +Mickey Mouse,115 +Minnie Mouse,116 +Moana,117 +Mulan,118 +Peter Pan,119 +Pongo,120 +Rapunzel,121 +Scar,122 +Scar,123 +Sergeant Tibbs,124 +Stitch,125 +Te Kā,126 +Tigger,127 +Be Prepared,128 +Cut to the Chase,129 +Dragon Fire,130 +Fan the Flames,131 +He's Got a Sword!,132 +Tangle,133 +Poisoned Apple,134 +Shield of Virtue,135 +Sword of Truth,136 +Ariel,137 +Aurora,138 +Aurora,139 +Aurora,140 +Belle,141 +Belle,142 +Chief Tui,143 +Donald Duck,144 +Flounder,145 +Gramma Tala,146 +Hades,147 +Jasmine,148 +Jasmine,149 +Maleficent,150 +Maleficent,151 +Maurice,152 +Merlin,153 +Mickey Mouse,154 +Mufasa,155 +Philoctetes,156 +Robin Hood,157 +Scar,158 +Tamatoa,159 +Triton,160 +Develop Your Brain,161 +If it’s Not Baroque,162 +Let It Go,163 +One Jump Ahead,164 +Work Together,165 +Coconut Basket,166 +Eye of the Fates,167 +Fishbone Quill,168 +Magic Golden Flower,169 +Scepter of Arendelle,170 +Aladdin,171 +Beast,172 +Captain Hook,173 +Captain Hook,174 +Captain Hook,175 +Cerberus,176 +Donald Duck,177 +Gantu,178 +Goons,179 +Hans,180 +Hercules,181 +Kristoff,182 +Kronk,183 +Lilo,184 +Maui,185 +Mickey Mouse,186 +Prince Eric,187 +Simba,188 +Simba,189 +Simba,190 +Starkey,191 +Te Kā,192 +Tinker Bell,193 +Tinker Bell,194 +A Whole New World,195 +Break,196 +Fire the Cannons!,197 +Grab Your Sword,198 +Ransack,199 +Smash,200 +Beast’s Mirror,201 +Frying Pan,202 +Musketeer Tabard,203 +Plasma Blaster,204 +Hades,205 +Stitch,206 +Elsa,207 +Mickey Mouse,208 +Genie,209 +Mickey Mouse,210 +Aladdin,211 +Maui,212 +Aurora,213 +Belle,214 +Simba,215 +Tinker Bell,216