宝石'推特'。解析仅返回推文的一部分

时间:2018-01-24 23:24:08

标签: ruby-on-rails ruby twitter

我正在使用twitter gem。请告诉我为什么在解析时我只得到推文的一部分?看看(live demo)。

例如:

Yeah, we don't want to hear from you. You've been yapping away for a million years. And by the w… 
Then, ‘for balance’ you need to also clearly and repe…
You stated as fact that there would be a #Brexit dividend,…

这是我的代码:

控制器

@arr = []
client.search("@#{params[:twitter_acc]}", result_type: "recent")
      .take(params[:number_of_tweets].to_i)
      .collect do |tweet|
  @arr << tweet
            .text
            .gsub("@#{params[:twitter_acc]}", "")
            .gsub("RT :", "")
            .gsub("RT", "")
end

查看

<% @arr.uniq.each do |line| %>
  <%= line %><br>
<% end %>

我该如何解决这个问题? 有什么想法吗?

更新

Tweet_parser. Result screenshot

1 个答案:

答案 0 :(得分:0)

试试这个:

@arr = []
client.search("@#{params[:twitter_acc]}", result_type: "recent", tweet_mode: "extended")
      .take(params[:number_of_tweets].to_i)
      .collect do |tweet|
  @arr << tweet
            .full_text
            .gsub("@#{params[:twitter_acc]}", "")
            .gsub("RT :", "")
            .gsub("RT", "")
end