Open ZhouMingjie-code opened 1 year ago
@ZhouMingjie-code
The find_element function has been changed in the new selenium version, you can find more here
To fix the issue, navigate to the google_images_download.py file then find and change the following:
browser.find_element_by_css_selector("[aria-label='Accept all']").click()
change to browser.find_element(By.CSS_SELECTOR, "[aria-label='Accept all']").click()
element = browser.find_element_by_tag_name("body")
change to element = browser.find_element(By.TAG_NAME, "body")
browser.find_element_by_xpath('//input[@value="Show more results"]').click()
change to browser.find_element(By.XPATH, '//input[@value="Show more results"]').click()
Don't forget to import: from selenium.webdriver.common.by import By
You can also copy-paste the file from here
@ZhouMingjie-code
The find_element function has been changed in the new selenium version, you can find more here
To fix the issue, navigate to the google_images_download.py file then find and change the following:
browser.find_element_by_css_selector("[aria-label='Accept all']").click()
change tobrowser.find_element(By.CSS_SELECTOR, "[aria-label='Accept all']").click()
element = browser.find_element_by_tag_name("body")
change toelement = browser.find_element(By.TAG_NAME, "body")
browser.find_element_by_xpath('//input[@value="Show more results"]').click()
change tobrowser.find_element(By.XPATH, '//input[@value="Show more results"]').click()
Don't forget to import:
from selenium.webdriver.common.by import By
You can also copy-paste the file from here
it still didnt work. Can you help ? One more thing that it is enough to copy google_images_download.py and paste then use it ? i'ım using ChromeDriver 108.0.5359.71 and Google Chrome 108.0.5359.125
The error i got when i try to run:
Item no.: 1 --> Item name = Man face Evaluating... Starting Download... 'NoneType' object is not subscriptable Traceback (most recent call last): File "C:/Users/livan/Python_Projects/G_ImagesDownload/DownloadImages.py", line 33, in downloadimages response.download(arguments) File "C:\Users\livan\Python_Projects\G_ImagesDownload\lib\site-packages\google_images_download\google_images_download.py", line 971, in download paths, errors = self.download_executor(arguments) File "C:\Users\livan\Python_Projects\G_ImagesDownload\lib\site-packages\google_images_download\google_images_download.py", line 1120, in download_executor arguments) # get all image items and download images File "C:\Users\livan\Python_Projects\G_ImagesDownload\lib\site-packages\google_images_download\google_images_download.py", line 907, in _get_all_items object['image_link'], object['image_format'], main_directory, dir_name, count, TypeError: 'NoneType' object is not subscriptable python-BaseException
i could sove the problem by creating new project and installed by this command
pip install google_images_download
then i've copied and pasted the changed you've mentioned after that i got another error which is mentioned here and after this it worked.
I used version 108 of chrome and chromedriver, and python 3.6. Thanks for everybody.
@ZhouMingjie-code
The find_element function has been changed in the new selenium version, you can find more here
To fix the issue, navigate to the google_images_download.py file then find and change the following:
browser.find_element_by_css_selector("[aria-label='Accept all']").click()
change tobrowser.find_element(By.CSS_SELECTOR, "[aria-label='Accept all']").click()
element = browser.find_element_by_tag_name("body")
change toelement = browser.find_element(By.TAG_NAME, "body")
browser.find_element_by_xpath('//input[@value="Show more results"]').click()
change tobrowser.find_element(By.XPATH, '//input[@value="Show more results"]').click()
Don't forget to import:
from selenium.webdriver.common.by import By
You can also copy-paste the file from here
@zahir2000's solution above in addition to changing info = data[9]
to info = data[23]
on line 406 worked for me. Thanks so much for providing the file as well!!
I want to get more than 100 images. So I try the "chromedriver".
Here is my code:
from google_images_download import google_images_download
response = google_images_download.googleimagesdownload()
arguments = {"keywords":"Michael Jordan","limit":200,"print_urls":True ,"raw_google_data":True,"no_download":True, "chromedriver":"C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"}
paths = response.download(arguments)
Here is the result: Item no.: 1 --> Item name = Michael Jordan Evaluating... Traceback (most recent call last): File "C:/Users/MJ Zhou/PycharmProjects/SEV/download_image.py", line 8, in
paths = response.download(arguments) #passing the arguments to the function
File "D:\anaconda3\envs\paper1\lib\site-packages\google_images_download-2.8.0-py3.8.egg\google_images_download\google_images_download.py", line 970, in download
File "D:\anaconda3\envs\paper1\lib\site-packages\google_images_download-2.8.0-py3.8.egg\google_images_download\google_images_download.py", line 1111, in download_executor
File "D:\anaconda3\envs\paper1\lib\site-packages\google_images_download-2.8.0-py3.8.egg\google_images_download\google_images_download.py", line 310, in download_extended_page
AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector'
How to solve this problem?