Skip to content

Commit

Permalink
Sat, Aug 3, 2024, 9:50 AM +03:00
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdoullahBougataya committed Aug 3, 2024
1 parent 389a675 commit 2eb37da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion database_updater.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sqlite3
import scrapper
import images_scrapper

con = sqlite3.connect('db\database.db')

Expand All @@ -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)):
Expand All @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions images_scrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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

0 comments on commit 2eb37da

Please sign in to comment.