2017-10-12 89 views
0

當某人發佈只包含網址的推文時,Twitter會在抓取網頁中的某些文本和圖片的位置進行一些修改。Twitter API - 有沒有辦法從推文中檢索文本和圖片?

下例:

enter image description here

有來自Twitter的API獲取這些數據的方法嗎?我無法在返回的任何內容中找到這些數據。我需要提供一些特殊的參數嗎?或者這只是不可能的事情?

回答

3

不可以。您無法從Twitter API獲取該數據。

您正在查看的數據是Twitter Card

這是它的工作原理。

的Web開發人員提出了一些meta標籤在他們的網頁 - 看看源爲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網站上顯示一張照片和標題。

如果要檢索該數據,則需要訪問URL並查找OpenGraph標記。

相關問題