Closed 0xbe1 closed 2 years ago
Read the README
Hi @ospfranco, thanks for the reply! I have read README though I didn't find the answer. Could you please help explain? Thanks a lot!
You cannot do cross-domain requests from a browser
You cannot do cross-domain requests from a browser
Oh, it is through my backend proxy, let me update the issue description. Here's the backend log
INFO: None:0 - "GET /cors_proxy/https%3A//twitter.com/elonmusk/status/1515799688296943636 HTTP/1.1" 200 OK
Can you help revisit the issue? Thanks!
Then it is not a problem with the library, as you can see you can get the response from youtube, so Twitter is not returning the correct headers/information to extract the info.
It either purposefully does not return this info (maybe due to some user config?) or is not using OpenGraph tags, or changed the response shape so the parsing/extracting is not working.
As stated in the README you will have to debug this type of issue yourself. The code is fairly simple, it just fetches the HTML and looks for the correct OpenGraph tags. If the info is there, you can submit a PR that tries to take care of exceptional cases by parsing other tags. Otherwise, the info is just not there and there is nothing that can be done about it.
Then it is not a problem with the library, as you can see you can get the response from youtube, so Twitter is not returning the correct headers/information to extract the info.
It either purposefully does not return this info (maybe due to some user config?) or is not using OpenGraph tags, or changed the response shape so the parsing/extracting is not working.
As stated in the README you will have to debug this type of issue yourself. The code is fairly simple, it just fetches the HTML and looks for the correct OpenGraph tags. If the info is there, you can submit a PR that tries to take care of exceptional cases by parsing other tags. Otherwise, the info is just not there and there is nothing that can be done about it.
@ospfranco thank you so much for the details, I will try to PR if I can. Thanks a lot, again :)
Since this is a social network it could also be an issue with redirections or facing a login screen redirection. In any case, the library is so simple that 98% of the time it is not a problem with the code, but just how the services respond to requests.
Describe the bug Not able to fetch title, description, and images for a tweet
To Reproduce Steps to reproduce the behavior:
getLinkPreview('https://twitter.com/elonmusk/status/1515799688296943636', {proxyUrl: xxx}).then(data => console.log(data))
User-agent: Twitterbot
to headers give me the same resultHowever, I am able to get all these info for a Youtube link https://www.youtube.com/watch?v=MejbOFk7H6c.
Expected behavior Should get description and images of the tweet https://twitter.com/elonmusk/status/1515799688296943636
Screenshots Here's the tweet:
Desktop (please complete the following information):
Additional context Thank you very much for the library, and appreciate your help in advance!!!