Twitter API - 无论如何都要检索已删除的文本&来自推特的图片?

时间:2017-10-12 13:45:42

标签: twitter

当有人发布只包含网址的推文时,Twitter会抓取一些文字和网页图片。

以下示例:

enter image description here

有没有办法从Twitter API中检索这些数据?我无法在返回的任何内容中找到此数据。我是否需要提供一些特殊参数?或者这只是不可能的事情?

1 个答案:

答案 0 :(得分:3)

没有。您无法从Twitter API获取该数据。

您看到的数据是Twitter Card

以下是它的工作原理。

网页开发人员在其网页中添加了一些元标记 - 请查看https://www.nytimes.com/2017/10/04/well/move/for-your-brains-sake-keep-moving.html的来源,然后您会看到:

<meta name="twitter:site" value="@nytimes" />
<meta property="twitter:url" content="https://www.nytimes.com/2017/10/04/well/move/for-your-brains-sake-keep-moving.html" />
<meta property="twitter:title" content="For Your Brain’s Sake, Keep Moving" />
<meta property="twitter:description" content="Exercise changes the workings of new brain cells in ways that may protect against dementia, a study in mice suggests." />
<meta property="twitter:image" content="https://static01.nyt.com/images/2017/10/10/well/04physed-brain-photo/04physed-brain-photo-videoSixteenByNineJumbo1600.jpg" />
<meta name="twitter:card" value="summary_large_image" />

当Twitter看到一个URL时,它会抓取它并查找这些标签。如果找到它们,它将在Twitter网站上显示照片和标题。

如果您想要检索该数据,则需要访问该网址并查找OpenGraph代码。