<commit_before># Write a program that goes to a photo-sharing site like Flickr or Imgur,
# searches for a category of photos, and then downloads all the resulting images.
# You could write a program that works with any photo site that has a search feature.

import requests, os, bs4
from selenium import webdriver, common

# Open Browser to photo-sharing site
url = "https://imgur.com/search?q="     # starting url
os.makedirs("images", exist_ok=True)    # store images in ./images

browser = webdriver.Firefox()

# Search for category of photos
browser.get(url + "Cats")

# Download all images
try:
    imageElems = browser.find_elements_by_css_selector("a.image-list-link")
    print(imageElems)
    for element in imageElems:
        downloadUrl = element.__getattribute__("href") + "#"
        # TODO: Save image to ./images
except common.exceptions.NoSuchElementException as err:
    print("Unable to locate element: %s" % err)<commit_msg>Update P2_imageDownloader add implicit wait and fix get_attribute<commit_after># Write a program that goes to a photo-sharing site like Flickr or Imgur,
# searches for a category of photos, and then downloads all the resulting images.
# You could write a program that works with any photo site that has a search feature.

import requests, os, bs4
from selenium import webdriver, common

# Open Browser to photo-sharing site
url = "https://imgur.com/search?q="     # starting url
os.makedirs("images", exist_ok=True)    # store images in ./images

browser = webdriver.Firefox()
browser.implicitly_wait(10)  # seconds

# Search for category of photos
browser.get(url + "Cats")

# Download all images
try:
    imageElems = browser.find_elements_by_css_selector("a.image-list-link")
    for element in imageElems:
        downloadUrl = element.get_attribute("href") + "#"
        print(downloadUrl)
        # TODO: Save image to ./images
except common.exceptions.NoSuchElementException as err:
    print("Unable to locate element: %s" % err)
{'fraction_non_alphanumeric': 0.08884401817264008, 'fraction_numerical': 0.002523977788995457, 'mean_word_length': 4.1214470284237725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '144235', 'n_tokens_mistral': 586, 'n_tokens_neox': 560, 'n_words': 216}