@@ -0,0 +1,1436 @@
+%22%22%22Fetches latest card names and links from hearthpwn.%0D%0A%0D%0AOutputs to cards.csv.%0D%0A%22%22%22%0D%0Aimport bs4%0D%0Aimport collections%0D%0Aimport csv%0D%0Aimport httplib2%0D%0Aimport logging%0D%0Aimport re%0D%0A%0D%0Aimport util%0D%0A%0D%0Adef get_cards_from_page(url):%0D%0A    logging.info(%22getting cards from %7B%7D%22.format(url))%0D%0A    card_dict = collections.OrderedDict()%0D%0A    http = httplib2.Http()%0D%0A    status, response = http.request(url)%0D%0A    for link in bs4.BeautifulSoup(response, parse_only=bs4.SoupStrainer('a')):%0D%0A        if link.has_attr(%22href%22) and link.has_attr(%22data-id%22):%0D%0A            card_dict%5Blink.text%5D = link%5B'href'%5D%0D%0A    return card_dict%0D%0A    %0D%0A%0D%0A%0D%0Adef main():%0D%0A    util.setup_logging(verbose=False)%0D%0A    logging.info(%22Starting generate_card_csv.py%22)%0D%0A%0D%0A    # Grab the cards from each page. We're purposely grabbing from more pages%0D%0A    # than exist. We're using a dict, so grabbing from pages more than once%0D%0A    # won't dupe cards.%0D%0A    card_dict = collections.OrderedDict()%0D%0A    for page_num in range(0, 10):%0D%0A        url = %22http://www.hearthpwn.com/cards?display=1&page=%7B%7D%22.format(page_num)%0D%0A        card_dict.update(get_cards_from_page(url))%0D%0A    logging.debug(%22card dict: %7B%7D%22.format(card_dict))%0D%0A%0D%0A    logging.info(%22writing cards to file%22)%0D%0A    with open(%22cards.csv%22, 'w') as csv_file:%0D%0A        csv_writer = csv.writer(csv_file)%0D%0A        for card in card_dict:%0D%0A            csv_writer.writerow(%5Bcard, card_dict%5Bcard%5D%5D)%0D%0A%0D%0A%0D%0Aif __name__ == %22__main__%22:%0D%0A    main()%0D%0A

add new generate_card_csv.py