-
Notifications
You must be signed in to change notification settings - Fork 0
/
nl_pkmn_fandom_list_generator.py
33 lines (20 loc) · 1.07 KB
/
nl_pkmn_fandom_list_generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import argparse
import importlib
from pokemon_lists.list_scraper_factory import ListScraperFactory
def main():
parser = argparse.ArgumentParser(description='Scrape a website and convert the data to a list format usable by the'
' Dutch Pokémon fandom/.')
parser.add_argument('-url', action="store", help='Target url', required=True)
parser.add_argument('-type', action="store", help='Source type of website being scraped, options', type=str, choices=["serebii"], default="serebii")
args = parser.parse_args()
scraper_class = ListScraperFactory().create(source_type=args.type, url=args.url)
try:
formatted_fandom_list = scraper_class.scrape()
text_file = open("output.txt", "w")
text_file.write(formatted_fandom_list)
text_file.close()
print("Done! Dutch Fandom formatted text can be found in output.txt")
except Exception as e:
print("Something went wrong during scraping, the source site may have changed its format.")
if __name__ == "__main__":
main()