meyt / linkpreview

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

Javascript not available for twitter links only #21

Closed narayanan-ka closed 1 year ago

narayanan-ka commented 1 year ago

Hi @meyt. I'm on Django-REST API 3.2 , using postman the results of link preview are as follows :

For twitter:

{ "site_name": "Twitter", "title": "JavaScript is not available.", "description": "We’ve detected that JavaScript is disabled in this browser. Please enable JavaScript or switch to a supported browser to continue using twitter.com. You can see a list of supported browsers in our Help Center.", "image": null, "absolute_image": null, "force_title": "JavaScript is not available." }

For Links other than twitter:

{ "site_name": "The Verge", "title": "Two years later, Netflix is still experimenting with games", "description": "Netflix has become a serious video game publisher.", "image": "https://cdn.vox-cdn.com/thumbor/BOil0LlEqGz5gPj4LO_zTGDElf0=/0x0:1920x1080/1200x628/filters:focal(754x440:755x441)/cdn.vox-cdn.com/uploads/chorus_asset/file/24814361/oxenfreequeens_gambit.png", "absolute_image": "https://cdn.vox-cdn.com/thumbor/BOil0LlEqGz5gPj4LO_zTGDElf0=/0x0:1920x1080/1200x628/filters:focal(754x440:755x441)/cdn.vox-cdn.com/uploads/chorus_asset/file/24814361/oxenfreequeens_gambit.png", "force_title": "Two years later, Netflix is still experimenting with games" }

For Twitter , I'm getting Javascript not available , Anything that I'm missing ?

You helped me to convert the link_preview(link).to_dict() the other day for Serialization. The results are as above.

meyt commented 1 year ago

@narayanan-ka https://github.com/meyt/linkpreview/issues/9#issuecomment-925643793

narayanan-ka commented 1 year ago

Hi@meyt The useragent bot changes recommended aren't already part of the package ? I saw code for Twitter card too, are they for something else ?

meyt commented 1 year ago

@narayanan-ka No, you must set it manually.

narayanan-ka commented 1 year ago

@narayanan-ka No, you must set it manually.

Understood. I need to replace the headers with the one you recommended or write a if condition for Twitter specially to use a header ?

Another question : I saw code for Twitter already in the package , any specific reason headers weren't updated for us to put it out manually ?

meyt commented 1 year ago

@narayanan-ka The TwitterCard is related to meta tag standard defined by Twitter.

Using header or any other tricks to have successful requests need a lot of effort. I can't maintain such stuff.

narayanan-ka commented 1 year ago

@narayanan-ka The TwitterCard is related to meta tag standard defined by Twitter.

Using header or any other tricks to have successful requests need a lot of effort. I can't maintain such stuff.

Well ok. Will the header user agent (Google bot) you recommended in the post for Twitter work for other links ? If yes, I can bypass the if condition to use only 1 header.

meyt commented 1 year ago

@narayanan-ka Yes