From 98219f3ad50a5b60f2113a0a4fb038180f0234b0 Mon Sep 17 00:00:00 2001 From: anela Date: Fri, 21 Apr 2023 14:02:26 -0700 Subject: [PATCH] Scrapes data for New Mexico games Debugged type error. --- lottery_data_scraper/new_mexico.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lottery_data_scraper/new_mexico.py b/lottery_data_scraper/new_mexico.py index 924db38..b7ce12e 100644 --- a/lottery_data_scraper/new_mexico.py +++ b/lottery_data_scraper/new_mexico.py @@ -7,7 +7,6 @@ import traceback from bs4 import BeautifulSoup as bs from lottery_data_scraper.schemas import GameSchema from lottery_data_scraper.util import fetch_html -from lottery_data_scraper.util import save_image logger = logging.getLogger(__name__) @@ -79,8 +78,6 @@ def process_game(game_info): num_of_tix = int(prizes[0]["odds"] * prizes[0]["total"]) image_url = game_html.find("div", class_="scratcher-image").find_next("img")["src"] - # FIXME: "image_urls" currently NoneType and not passing GameSchema - # image_location = save_image("nm", game_id, image_url, headers=HEADERS) game = { "name": name, @@ -90,8 +87,7 @@ def process_game(game_info): "prizes": prizes, "num_tx_initial": num_of_tix, "state": "nm", - # "image_urls": '["{}"]'.format(image_url), - "image_urls": f'["{{image_url}}"]', + "image_urls": f'["{image_url}"]', } return game @@ -108,8 +104,10 @@ def main(): logger.warning(f"Unable to process game: {game[0]}-{game[1]}") logger.warning(e) traceback.print_exception(e) + return final_games + if __name__ == "__main__": games = main() schema = GameSchema(many=True) - print(schema.dumps(games)) \ No newline at end of file + print(schema.dumps(games))