meyt/linkpreview

Doesn't work with google.com ?

Closed this issue · 4 comments

Won't get any image when

>>> link_preview('https://google.com').absolute_image, 
(None,)

and without https the link wont work

>>> link_preview('http://google.com').absolute_image, 
('http://google.com/images/branding/googleg/1x/googleg_standard_color_128dp.png',)

List of links that don't work properly:

meyt commented

@rickerp Here is what i tried:

from linkpreview import link_preview

links = (
    'http://google.com',
    'https://google.com',
    'http://amazon.com',
    'http://youtube.com',
)
for l in links:
    print('=' * 80)
    print('URL:', l)
    try:
        preview = link_preview(l)
        print("title:", preview.title)
        print("description:", preview.description)
        print("image:", preview.image)
        print("force_title:", preview.force_title)
        print("absolute_image:", preview.absolute_image)
    except Exception as e:
        print('Failed', e)

results:

================================================================================
URL: http://google.com
title: Google
description: Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
image: /images/branding/googleg/1x/googleg_standard_color_128dp.png
force_title: Google
absolute_image: http://google.com/images/branding/googleg/1x/googleg_standard_color_128dp.png
================================================================================
URL: https://google.com
title: Google
description: Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
image: /images/branding/googleg/1x/googleg_standard_color_128dp.png
force_title: Google
absolute_image: https://google.com/images/branding/googleg/1x/googleg_standard_color_128dp.png
================================================================================
URL: http://amazon.com
Failed 503 Server Error: Service Unavailable for url: https://www.amazon.com/
================================================================================
URL: http://youtube.com
title: YouTube
description: Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
image: https://www.youtube.com/img/desktop/yt_1200.png
force_title: YouTube
absolute_image: https://www.youtube.com/img/desktop/yt_1200.png

All links work, except the Amazon because of their security check, may need some modification on request headers (User-Agent, etc).

Please try curl -vv or the LinkGrabber to get more details.

I think it is because of the region, I'm currently in Portugal and don't have those results.
And if you access that image urls from google (http://google.com/images/branding/googleg/1x/googleg_standard_color_128dp.png) you will get a 404

meyt commented

@rickerp Fixed, Now on v0.2.0 it returns the right image URL.