如何检索.net中时间范围内的所有推文 [英] How to retreive all tweets in time range in .net

查看:66
本文介绍了如何检索.net中时间范围内的所有推文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要撤消某个时间范围内(例如最近7天)的所有推文,而与制作这些推文的用户无关.另外,我想将它们存储在数据库中以便以后使用.如何在.net中做到这一点.

有人可以帮我吗?我迫切需要这个.

提前谢谢!

Shikha

Hi all,

I need to retreive all the tweets in a time range (say for last seven days), irrespective of the user who made them. Also,I want to store them in database so that I can use them later.How can I do this in .net .

Can anybody please help me. I need this urgently.

Thanks in advance!

Shikha

推荐答案

使用Search API将数据转换为XML

http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-search [ ^ ]

将XML读入一些对象,例如

http://blogs. msdn.com/b/roberthorvick/archive/2009/01/27/reading-twitter-data-with-c-and-linq.aspx [
Use the Search API to get the data into XML

http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-search[^]

Read the XML into some objects, e.g

http://blogs.msdn.com/b/roberthorvick/archive/2009/01/27/reading-twitter-data-with-c-and-linq.aspx[^]

Now write them to a database of your choice!


我需要检索某个时间范围内(例如最近7天)的所有tweet,无论用户是谁他们."


您肯定不能说每天所有Tweets ,每天有超过5000万条-每天都有大量的数据.也许您应该考虑以某种方式过滤它们.

:)
"I need to retreive all the tweets in a time range (say for last seven days), irrespective of the user who made them."


You surely can''t mean all Tweets in a day, there are over 50 million per day - that''s an awfull lot of data each day. Perhaps you should think about filtering them in some way.

:)


API说这是可选的

q:可选.要搜索的文本.有关此参数支持的语法示例,请参见示例查询部分.

例如

http://search.twitter.com/search.json?&q=twitter [ ^ ]

因此,请尝试使用since参数

http://search.twitter.com/search.atom?since=2010-02-28 [ ^ ]

毫无疑问,这将失败,因为正如艾莉森(Alison)指出的那样,要通过网络返回的数据量非常大. Twitter可能有一些资源限制\超时选项,否则运行此类查询的人将不断使网站瘫痪.

您将不得不考虑如何通过结合使用参数来缓冲数据并分块检索

最好 since_id max_id 是最好的选择,例如

块1
http://search.twitter.com/search.atom?since_id=1520000000&max_id=1520100000

块2
http://search.twitter.com/search.atom?since_id=1520100000&max_id=1520200000

等等等等

即使使用大量请求检索小数据,您也将消耗带宽和如果您发现自己的IP被列入黑名单,我不会感到惊讶!不知道用5,000万个疯狂的评论刷牙"和要吃早餐"可能会想要什么
The API says this is optional

q: Optional. The text to search for. See the example queries section for examples of the syntax supported in this parameter

e.g

http://search.twitter.com/search.json?&q=twitter[^]

So try just with the since parameter

http://search.twitter.com/search.atom?since=2010-02-28[^]

This will undoubtedly fail though because as Alison has pointed out, it''s a very large amount of data to return over the wire. Twitter probably have some resource limit \ timeout options otherwise people running these sort of queries would constantly bring the site down.

You going to have to think about how to buffer the data and retrieve in chunks by using a combination of parameters

Possibly since_id and max_id are best bet, e.g

Chunk 1
http://search.twitter.com/search.atom?since_id=1520000000&max_id=1520100000

Chunk 2
http://search.twitter.com/search.atom?since_id=1520100000&max_id=1520200000

etc etc

Even retrieving small data using lots of requests, you''re going to chew up bandwidth & I wouldn''t be surprised if you find your IP being blacklisted! Don''t know what you could possibly want with 50m inane comments about ''brushing my teeth'' and ''about to have breakfast''


这篇关于如何检索.net中时间范围内的所有推文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆