[GH-ISSUE #3] "View Image" functionality. #3

Closed
opened 2026-02-25 20:34:38 +03:00 by kerem · 13 comments
Owner

Originally created by @cole8888 on GitHub (May 10, 2020).
Original GitHub issue: https://github.com/benbusby/whoogle-search/issues/3

It would be pretty cool if we could incorporate the functionality from https://github.com/bijij/ViewImage which would give you the download link to a full sized image without having to visit the source website.

Originally created by @cole8888 on GitHub (May 10, 2020). Original GitHub issue: https://github.com/benbusby/whoogle-search/issues/3 It would be pretty cool if we could incorporate the functionality from https://github.com/bijij/ViewImage which would give you the download link to a full sized image without having to visit the source website.
kerem 2026-02-25 20:34:38 +03:00
Author
Owner

@benbusby commented on GitHub (May 15, 2020):

Just want to note that the framework for this feature is already started, if anyone wanted to jump in ahead of me and look into it some more. Part of the Filter class has a commented out section with a TODO, seen here:

# TODO: Non-mobile image results link to website instead of image
# if not self.mobile:
    # img.append(BeautifulSoup(FULL_RES_IMG.format(img_src), 'html.parser'))

where FULL_RES_IMG is just a stringified html linebreak and link tag, with formatting in place for the full res link:

FULL_RES_IMG = '<br/><a href="{}">Full Image</a>'

If the code to fetch the full size image url is fairly straight forward, all that would need to be done is replace img_src in the formatting section with the full size image url. Though that could be easier said than done, still haven't had a good chance to look through the ViewImage extension to see how that all works.

<!-- gh-comment-id:629545090 --> @benbusby commented on GitHub (May 15, 2020): Just want to note that the framework for this feature is already started, if anyone wanted to jump in ahead of me and look into it some more. Part of the `Filter` class has a commented out section with a TODO, seen here: ```python # TODO: Non-mobile image results link to website instead of image # if not self.mobile: # img.append(BeautifulSoup(FULL_RES_IMG.format(img_src), 'html.parser')) ``` where `FULL_RES_IMG` is just a stringified html linebreak and link tag, with formatting in place for the full res link: ```python FULL_RES_IMG = '<br/><a href="{}">Full Image</a>' ``` If the code to fetch the full size image url is fairly straight forward, all that would need to be done is replace `img_src` in the formatting section with the full size image url. Though that could be easier said than done, still haven't had a good chance to look through the ViewImage extension to see how that all works.
Author
Owner

@jacr13 commented on GitHub (May 26, 2020):

I have take a look at this feature and it seems that google load the true image url using javascript.
Since pycurl doesn't support javascript the true urls are impossible to get as it is...

<!-- gh-comment-id:634011749 --> @jacr13 commented on GitHub (May 26, 2020): I have take a look at this feature and it seems that google load the true image url using javascript. Since pycurl doesn't support javascript the true urls are impossible to get as it is...
Author
Owner

@Aikatsui commented on GitHub (Oct 8, 2020):

@benbusby you have mentioned about google's images results implementation then i dont consider to open seperate issue.
Currently default images view page isn't soo good so i prefer if you can enhance it bit.

<!-- gh-comment-id:705352981 --> @Aikatsui commented on GitHub (Oct 8, 2020): @benbusby you have mentioned about google's images results implementation then i dont consider to open seperate issue. Currently default images view page isn't soo good so i prefer if you can enhance it bit.
Author
Owner

@federicotorrielli commented on GitHub (Apr 2, 2021):

Hey @benbusby I would like to work on this feature, where should I start?

<!-- gh-comment-id:812444846 --> @federicotorrielli commented on GitHub (Apr 2, 2021): Hey @benbusby I would like to work on this feature, where should I start?
Author
Owner

@jacr13 commented on GitHub (Apr 2, 2021):

Hey @benbusby I would like to work on this feature, where should I start?

You should start to find a way to extract the real URL of an image (not the embedded version of google); if you have these URLs, the following is trivial.
As I said before, the problem is that these URLs are loaded with javascript...

<!-- gh-comment-id:812472770 --> @jacr13 commented on GitHub (Apr 2, 2021): > Hey @benbusby I would like to work on this feature, where should I start? You should start to find a way to extract the real URL of an image (not the embedded version of google); if you have these URLs, the following is trivial. As I said before, the problem is that these URLs are loaded with javascript...
Author
Owner

@benbusby commented on GitHub (Apr 2, 2021):

@federicotorrielli what @jacr13 said is correct, although javascript solutions like the ViewImage repo linked in this issue don't work anymore (for me, at least).

One possible alternative to look into is somehow matching the desktop URL with the mobile URL, and using the mobile one for viewing the image at full resolution. Google's results seem to return the actual full size image link on mobile, but only a link to the source of the image on desktop. It might be a little hacky, but I think it would work.

An alternative to that alternative would be to just force the desktop image search to always return mobile results. The downsides of that would be that selecting the image would only ever return the (presumably full size) image itself and not the image source, and the layout of the mobile image search on desktop would look pretty bad without some additional styling.

Either way I think the bulk of the work would have to be in filter.py since that's where all of the HTML parsing occurs.

<!-- gh-comment-id:812504082 --> @benbusby commented on GitHub (Apr 2, 2021): @federicotorrielli what @jacr13 said is correct, although javascript solutions like the ViewImage repo linked in this issue don't work anymore (for me, at least). One possible alternative to look into is somehow matching the desktop URL with the mobile URL, and using the mobile one for viewing the image at full resolution. Google's results seem to return the actual full size image link on mobile, but only a link to the source of the image on desktop. It might be a little hacky, but I think it would work. An alternative to that alternative would be to just force the desktop image search to always return mobile results. The downsides of that would be that selecting the image would only ever return the (presumably full size) image itself and not the image source, and the layout of the mobile image search on desktop would look pretty bad without some additional styling. Either way I think the bulk of the work would have to be in `filter.py` since that's where all of the HTML parsing occurs.
Author
Owner

@federicotorrielli commented on GitHub (Apr 2, 2021):

So, I tried to play a little bit with the code only to discover that this remains a huge problem. So, here's my two cents.

  1. Emulating a mobile page is really not doable and server heavy (first we get all the links from the mobile page, then we "paste" all the links to the desktop page, this keeps the client loading at least 1 second more)
  2. Playing with JS may be ok, but I don't really have that big knowledge of whoogle source code to implement it (This script is working, tho), and I need more time.

I will try to look into what I think is the best alternative, Google image search api. If all the request of the images are done to the API and not to the default search, it might be a cool way to get those faster.

<!-- gh-comment-id:812526005 --> @federicotorrielli commented on GitHub (Apr 2, 2021): So, I tried to play a little bit with the code only to discover that this remains a huge problem. So, here's my two cents. 1) Emulating a mobile page is really not doable and server heavy (first we get all the links from the mobile page, then we "paste" all the links to the desktop page, this keeps the client loading at least 1 second more) 2) Playing with JS may be ok, but I don't really have that big knowledge of whoogle source code to implement it ([This](https://gist.github.com/sudokai/2464bb1c94f492b1adad4152da68f435) script is working, tho), and I need more time. I will try to look into what I think is the best alternative, Google image search api. If all the request of the images are done to the API and not to the default search, it might be a cool way to get those faster.
Author
Owner

@federicotorrielli commented on GitHub (Apr 3, 2021):

So, bad news. Google search image query api is limited to 100 queries per day, and it's not exactly what we want right now, so I'll try with the JS solution. Right now I need to:

  1. Inject JS code into the Google page (see script in the previous message)
  2. Take the result and put it into every single image.
<!-- gh-comment-id:812845807 --> @federicotorrielli commented on GitHub (Apr 3, 2021): So, bad news. Google search image query api is limited to 100 queries per day, and it's not exactly what we want right now, so I'll try with the JS solution. Right now I need to: 1) Inject JS code into the Google page (see script in the previous message) 2) Take the result and put it into every single image.
Author
Owner

@jacr13 commented on GitHub (Apr 3, 2021):

I think you are missing something; the view image script works on google because it looks for url when the page is loaded in the browser. With whoogle the page is loaded without javascript so the urls are not present so even if you inject the script from view image it will not work I think... does the add-on work with the parameter gbv=1 in the query ?

<!-- gh-comment-id:812846291 --> @jacr13 commented on GitHub (Apr 3, 2021): I think you are missing something; the view image script works on google because it looks for url when the page is loaded in the browser. With whoogle the page is loaded without javascript so the urls are not present so even if you inject the script from view image it will not work I think... does the add-on work with the parameter gbv=1 in the query ?
Author
Owner

@federicotorrielli commented on GitHub (Apr 3, 2021):

@jacr13 Yes it does work (if I modify it). I'll try to study if I can somehow inject the js in the page I get from Google after the request.

EDIT: Actually, I forgot that Google gbv=1 does not come with any JS in it, so this is not possible, my mistake.
So the last thing we can try is the mobile one? Damn.

<!-- gh-comment-id:812846620 --> @federicotorrielli commented on GitHub (Apr 3, 2021): @jacr13 Yes it does work (if I modify it). I'll try to study if I can somehow inject the js in the page I get from Google after the request. EDIT: Actually, I forgot that Google gbv=1 does not come with any JS in it, so this is not possible, my mistake. So the last thing we can try is the mobile one? Damn.
Author
Owner

@jacr13 commented on GitHub (Apr 3, 2021):

Yes... for me the only way is to check if we are searching for images if it's the case request with mobile user agent get the resulting page and parse it to extract the url of the images. Than have a template html and add to it the images urls. Each image as no information about the web site (title etc) so each time we click on an image a collapse menu shloud appear and inside we should display the result of the request on google images with the real url of the image (without mobile user agent) this way we get metadata for the image (assuming the first image is the correct one) and some other images related. With this approche we can have the real image url and the url of the webpage where the image is.

<!-- gh-comment-id:812856438 --> @jacr13 commented on GitHub (Apr 3, 2021): Yes... for me the only way is to check if we are searching for images if it's the case request with mobile user agent get the resulting page and parse it to extract the url of the images. Than have a template html and add to it the images urls. Each image as no information about the web site (title etc) so each time we click on an image a collapse menu shloud appear and inside we should display the result of the request on google images with the real url of the image (without mobile user agent) this way we get metadata for the image (assuming the first image is the correct one) and some other images related. With this approche we can have the real image url and the url of the webpage where the image is.
Author
Owner

@jacr13 commented on GitHub (Apr 6, 2021):

Here is a solution that works: #268.
The thumbnails are a bit blurry but this is due to the fact that mobile thumbnails are very small.

<!-- gh-comment-id:814115594 --> @jacr13 commented on GitHub (Apr 6, 2021): Here is a solution that works: #268. The thumbnails are a bit blurry but this is due to the fact that mobile thumbnails are very small.
Author
Owner

@benbusby commented on GitHub (Apr 16, 2021):

Merged in #268 and available on the develop branch or beta/buildx-experimental images once the build finishes. Thanks again @jacr13!

<!-- gh-comment-id:821210103 --> @benbusby commented on GitHub (Apr 16, 2021): Merged in #268 and available on the `develop` branch or `beta`/`buildx-experimental` images once the build finishes. Thanks again @jacr13!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/whoogle-search#3
No description provided.