【发布时间】:2018-07-18 10:45:33
【问题描述】:
我想获取上个月内带有特定主题标签的推文中的所有图像。我目前正在使用 Ruby。在我的index.rb 文件中,我试图将以下代码存储在一个变量中:
@photos = client.search('#bestfriends', { include_entities: true, fromDate:"201801071200>",toDate:"201802071200", include_entities: true })
但是,当我在命令行上运行它时,我得到以下信息:
{:statuses=>
[{:created_at=>"Thu Feb 08 00:15:10 +0000 2018",
:id=>961392929762938880,
:id_str=>"961392929762938880",
:text=>
"FCC Says Releasing 'Jokes' It Wrote About Ajit Pai Illegally Colluding With Verizon (WHICH HAPPENED) Would 'Harm' A… ",
:truncated=>true,
:entities=>
{:hashtags=>[],
:symbols=>[],
:user_mentions=>[],
:urls=>
正如您从:hashtags=>[], 中看到的那样,标签是空的,我有办法根据日期范围内的标签获取推文吗?我正在使用https://github.com/sferik/twitter,但不知道使用https://github.com/twitter/twurl 是否更好,因为它来自命令行。
【问题讨论】:
-
这表示“截断:true”,因此您需要使用 tweet_mode=extended 参数来检索包括任何实体在内的完整 Tweet 对象。
-
我是否在查询中添加
tweet_mode=extended@AndyPiper?我的意思是这样的:client.search('#bestfriends', { tweet_mode: extended, include_entities: true, fromDate:"201801071200>",toDate:"201802071200", include_entities: true }) -
应该可以,但我不熟悉您直接使用的库。
-
@AndyPiper 你能嵌套查询吗?意思是如果我想检查
:entities内:urls是否为空?