diff --git a/database_updater.py b/database_updater.py index a862edb..695c3eb 100644 --- a/database_updater.py +++ b/database_updater.py @@ -1,5 +1,6 @@ import sqlite3 import scrapper +import images_scrapper con = sqlite3.connect('db\database.db') @@ -11,6 +12,8 @@ titles, engines = scrapper() +images = images_scrapper() + # Creating table table = """ CREATE TABLE rocket_engines (Id INTEGER NOT NULL PRIMARY KEY, """ for i in range(len(titles)): @@ -20,7 +23,7 @@ elif type(engines[17][i]) == float: table += """ REAL, """ table = table.removesuffix(""", """) -table += """); """ +table += """Image TEXT); """ cur.execute(table) print("Table is Ready") diff --git a/images_scrapper.py b/images_scrapper.py index 32c834c..34a6c74 100644 --- a/images_scrapper.py +++ b/images_scrapper.py @@ -31,6 +31,7 @@ def images_scrapper(): engines = scrapper()[1] paths = () for engine in engines: + path = "" engine_name = engine[0] goog_search = "https://www.google.com/search?sclient=psy-ab&client=ubuntu&hs=k5b&channel=fs&biw=1366&bih=648&noj=1&q=" + engine_name.replace(" ", "+") + "+rocket+engine+wikipedia" @@ -52,8 +53,9 @@ def images_scrapper(): if soup.find("table", {"class" : "infobox"}).find("td", {"class": "infobox-image"}).find("img").get("srcset"): if len(soup.find("table", {"class" : "infobox"}).find("td", {"class": "infobox-image"}).find("img").get("srcset").split()) > 2 and "Aeon" not in engine_name: pic_url = "https:" + str(soup.find("table", {"class" : "infobox"}).find("td", {"class": "infobox-image"}).find("img").get("srcset").split()[2]) - download_image(pic_url, f"./images/{engine_name}.jpg") - paths += f"./images/{engine_name}.jpg" + path = f"./images/{engine_name}.jpg" + download_image(pic_url, path) + paths += path return paths sys.modules[__name__] = images_scrapper