Skip to content

Commit 0fbfc89

Browse files
committed
Refactor code for speed and clarity
1 parent 8663bc4 commit 0fbfc89

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

beautiful_scraper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2+
13
import os
24
import re
35

bing_scraper.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2+
13
# Bing Images and Google Images web scraper
24
# Requires chromedriver. Download from https://chromedriver.chromium.org/
35

@@ -373,7 +375,7 @@ def user_input():
373375
# args.chromedriver = './chromedriver'
374376

375377
if args.search: # construct url
376-
args.url = f'https://www.bing.com/images/search?q={args.search.replace(" ", "%20")}'
378+
args.url = f"https://www.bing.com/images/search?q={args.search.replace(' ', '%20')}"
377379
args.image_directory = args.search.replace(" ", "_")
378380

379381
arguments = vars(args)
@@ -469,7 +471,7 @@ def get_next_tab(self, s):
469471
start_line = s.find('class="dtviD"')
470472
start_content = s.find('href="', start_line + 1)
471473
end_content = s.find('">', start_content + 1)
472-
url_item = f"https://www.google.com{str(s[start_content + 6:end_content])}"
474+
url_item = f"https://www.google.com{str(s[start_content + 6 : end_content])}"
473475
url_item = url_item.replace("&", "&")
474476

475477
start_line_2 = s.find('class="dtviD"')
@@ -799,7 +801,7 @@ def keywords_from_file(self, file_name):
799801
line.replace("\n", "").replace("\r", "") for line in f if line not in ["\n", "\r\n"]
800802
)
801803
else:
802-
print("Invalid file type: Valid file types are either .txt or .csv \n" "exiting...")
804+
print("Invalid file type: Valid file types are either .txt or .csv \nexiting...")
803805
sys.exit()
804806
return search_keyword
805807

clean_images.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2+
13
import glob
24
import os
35

0 commit comments

Comments
 (0)