Open eyjho opened 4 years ago
Interesting. I personally don't know why google images downloads needs a single image option as the requests module is a much better option for this case, as it is a more supported module.
Anyway, the single image argument does not seem to work with the downloads module instead use the single_image module. The code below should work:
from google_images_download import google_images_download
response = google_images_download.googleimagesdownload()
image_url = 'https://upload.wikimedia.org/wikipedia/commons/f/f1/Jack_Russell_Terrier_1.jpg'
response.single_image(image_url)
As for the command line, it will automatically use the single image module. The mistake you have, is that you have used single quotes, which will be parsed as part of the url. This made it think your url begun with 'https://
, hence the error message.
To fix that just use double quotes or no quotes at all like in the code below:
googleimagesdownload --keywords "jack russel" --single_image "upload.wikimedia.org/wikipedia/commons/f/f1/Jack_Russell_Terrier_1.jpg"
Hi.
I am a student studying Computer Science in Coventry University. I am interested to contribute to this project by attempting to enhance the download_page(), download_extended_page(), and single_image() functions.
Hello, i ve tested single image download and it works. I assume there's nothing wrong with internet connection. But somehow i try to download multiple image from code from here and it stucks in 'evaluating'. i havent re-read all of the code and what 'evaluating' does. Could you help me, is it something wrong happen during this process? thankyou in advance
btw this is my commandline working on the package
C:\Users\ASUS TUF GAMING\Desktop\image_downloader>python -m image_downloader.py
Item no.: 1 --> Item name = The smartphone also features an in display fingerprint sensor.
Evaluating...
and this is the image_downloader script
from google_images_download import google_images_download
response = google_images_download.googleimagesdownload()
search_queries = [
'The smartphone also features an in display fingerprint sensor.',
'The pop up selfie camera is placed aligning with the rear cameras.',
'''In terms of storage Vivo V15 Pro could offer
up to 6GB of RAM and 128GB of onboard storage.''',
'The smartphone could be fuelled by a 3 700mAh battery.',
]
def downloadimages(query):
arguments = {"keywords": query,
"format": "jpg",
"limit":4,
"print_urls":True,
"size": "medium",
"aspect_ratio":"panoramic"}
try:
response.download(arguments)
except FileNotFoundError:
arguments = {"keywords": query,
"format": "jpg",
"limit":4,
"print_urls":True,
"size": "medium"}
try:
response.download(arguments)
except:
pass
for query in search_queries:
downloadimages(query)
print()
i took it unedited from the source to test if it works
Hi @tectanagrand,
If you install _google_imagesdownload using pip install google_images_download
, you have a quite old version (21st May 2019 according this page) which can maybe explain your issue.
By installing the Joeclinton1's fork (thanks to the commands given in the first message of #298 ), I have no issue with your script :
thankyou for your recommendation @NicolasGrosjean, sorry for the late reply. i have tried the fork, but somehow it is still stuck in "Evaluating...". I'm confused with the problem because there isn't any error logs or warnings. Do you have any idea to troubleshoot the problem? Thanks in advance.
If your Python version is 2.X, try with a 3.X.
Except this idea, the only one thing I see is to run a debugger (for example with VScode or PyCharm) to see what it is the failing line of code.
Hello, this program has been incredibly useful, but I've gotten stuck while trying to download a single image in a Python script. I'm still relatively new to Python and these programs so forgive me if it's a silly question. The command (below) seems to ignore the single image argument entirely and simply proceed to download 100 images using the keywords. Having the keywords argument seems unnecessary to download an image from an url, but I get an error if the argument is not included (UnboundLocalError: local variable 'search_keyword' referenced before assignment).
To debug, I attempted to implement the example from the documentation. Although I am using a Python script, only a command line example is available using the single_image argument
googleimagesdownload --keywords "baloons" --single_image <URL of the images>
To which I get the following errors:
Since there seems to be some issues with the url, I tried some variants:
I checked the requests module in Python, and it seems to be working:
So I'll just be using this as a substitute, but would be great to use the google_images_download program feature.