meyt / linkpreview

Get link preview in python
MIT License
46 stars 9 forks source link

Absolute image returning wrong image path when image has a relative path #13

Closed hendrikschneider closed 2 years ago

hendrikschneider commented 2 years ago

Hello,

in the following url is a relative path used for the image: https://www.wirtschaftsfoerderung-hannover.de/de/Veranstaltungen/hannoverimpuls/Dos_and_Donts_des_E-Commerce.php/medien/bilder/hannoverimpuls/Logos/Screenshot_2022-10-18_121717_0.png

from linkpreview import link_preview
preview = link_preview("https://www.wirtschaftsfoerderung-hannover.de/de/Veranstaltungen/hannoverimpuls/Dos_and_Donts_des_E-Commerce.php/medien/bilder/hannoverimpuls/Logos/Screenshot_2022-10-18_121717_0.png")

preview.image
# /medien/bilder/hannoverimpuls/Logos/Screenshot_2022-10-18_121717_0.png?m=1666088811&

preview.absolute_image
# https://www.wirtschaftsfoerderung-hannover.de/de/Veranstaltungen/hannoverimpuls/Dos_and_Donts_des_E-Commerce.php/medien/bilder/hannoverimpuls/Logos/Screenshot_2022-10-18_121717_0.png/medien/bilder/hannoverimpuls/Logos/Screenshot_2022-10-18_121717_0.png?m=1666088811&

Expected result:

preview.absolute_image
# https://www.wirtschaftsfoerderung-hannover.de/medien/bilder/hannoverimpuls/Logos/Screenshot_2022-10-18_121717_0.png?m=1666088811&

A library such as tld extract could be helpful to retrieve the domain of a path but it also introduces a new depency.

hendrikschneider commented 2 years ago

Thanks for the fast support!