没有OAuth认证如何爬取twitter推文信息?

发布于 2024-10-08 21:55:23 字数 97 浏览 0 评论 0原文

我需要抓取 Twitter 并分析推文以获取信息。我认为最好的方法是使用搜索 API,但现在 api 似乎需要 OAuth 身份验证。注册成为开发者是唯一的方法吗?还有其他选择吗?

I'm required to crawl twitter and analyze the tweets for information. I figured the best way would be to use the search API, however it seems that now the api requires the OAuth authentication. Would registering as a developer be the only way? Are there alternatives?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

享受孤独 2024-10-15 21:55:23

自从 Twitter 关闭以来,亚当·格林(选择的)答案就不再起作用了
REST API v1.0。

如果您调用给定的示例来查询披萨:

http://search.twitter.com /search.json?q=pizza

您收到以下错误消息:(尽管是 json 格式;)

{"errors": 
   [{"message": "The Twitter REST API v1 is no longer active. 
      Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview",
     "code": 64}
   ]
}

您可以在此处查看 API 1.1 搜索规范

从 1.0 到 1.1 的另一个变化是所有 1.1 API 调用都需要身份验证
包括搜索。

The (chosen) answer of Adam Green is not working anymore since Twitter closed their
REST API v1.0.

If you call the given example to query for pizza:

http://search.twitter.com/search.json?q=pizza

You get the following error message: (in json, though ;)

{"errors": 
   [{"message": "The Twitter REST API v1 is no longer active. 
      Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview",
     "code": 64}
   ]
}

You can check the API 1.1 search spec here

Another change from 1.0 to 1.1 is that all 1.1 API Calls require an authentication
including search.

无需解释 2024-10-15 21:55:23

这里有很多错误信息。您不必进行屏幕抓取。您无需注册应用程序即可执行此操作。 Twitter 中没有 API 密钥。您无需使用任何授权即可从搜索 API 读取数据。 API 的其余部分需要 OAuth,但不需要搜索。

要使用搜索 API,您只需对以下 URL 发出请求:
http://search.twitter.com/search.json?q=[keywords ]

例如搜索披萨:
http://search.twitter.com/search.json?q=pizza

您将获得可在任何程序中读取的 JSON 数据。如果您使用 PHP,则可以使用 cURL 发出请求,并使用 json_decode() 将结果转换为可以在 foreach() 循环中迭代的对象。

Lots of misinformation here. You do not have to screen scrape. You do not have to register an app to do this. There are no API keys in Twitter. You do not have to use any authorization to read data from the search API. The rest of the API requires OAuth, but not search.

To use the search API you can just make a request against the following URL:
http://search.twitter.com/search.json?q=[keywords]

For example to search for pizza:
http://search.twitter.com/search.json?q=pizza

You get JSON data back that you can read in any program. If you use PHP, you can use cURL to make the request and json_decode() to convert the result into an object you can iterate through in a foreach() loop.

单身情人 2024-10-15 21:55:23

如果您想分析大量推文,则应使用Streaming API。您需要注册才能访问此内容。

您还可以使用无需注册的搜索 API。但这是有速率限制的。

If you want to analyse large amounts of tweets, you should be using the Streaming API. You will need to register for access to this.

You could also use the Search API for which you do not need to register. But this is rate limited.

叫思念不要吵 2024-10-15 21:55:23

您可以尝试 PythoncURL< /a>.

You could try Python or cURL.

安人多梦 2024-10-15 21:55:23

它很脏*,但您可以使用 PHP DOM 以重复的间隔抓取 Twitter 的主页。

*twitters 搜索 API 并不复杂,因此我猜您愿意使用快速破解

it is dirty*, but you could use PHP DOM to scrape Twitter's home page at repeated intervals.

*twitters search API is not complex, therefore I am guessing you are willing to use a quick hack.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文