在java中使用多个IP进行抓取

发布于 2024-08-25 08:28:03 字数 327 浏览 3 评论 0原文

基本上我有一个抓取应用程序。 它每分钟抓取大约 n 个项目。 目前我只有一个IP。

我正在抓取的网站允许每个 IP 有 3 个连接。

我正在考虑获得另一个IP。

这样我就可以获得 6 个连接。

理论上我应该能够在 40 秒内获得 n 件物品,或多或少。

目前我正在使用 java (commons-httpcore) 来完成工作。

我不确定这是java问题还是操作系统问题。

我的机器有IP 1和IP 2 我如何连接到 www.microsoft.com, 使用IP 1 和使用IP2? 我如何指定我想使用哪个 IP 进行连接?

Well basically I have a scraping application.
It scrapes around n items per minute.
currently i have only one IP.

The site i'm scraping allows me 3 connections per IP.

I'm thinking about getting another IP.

so i'll be able to get 6 connections.

in theory i should be able to get n items in 40 seconds, more or less.

currently i'm using java (commons-httpcore) to get the job done.

I'm not sure if this is java question or an OS question.

my machine has IP 1 and IP 2
how do i connect to, say, www.microsoft.com,
using IP 1 and using IP2?
how can i specify, which ip i want to use to do a connection?

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

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

发布评论

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

评论(1

来世叙缘 2024-09-01 08:28:03
// requires HttpComponents Client 4.*
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(
  ConnRoutePNames.LOCAL_ADDRESS, 
  InetAddress.getByName("10.10.10.10")
);

请参阅: http://hc.apache.org/httpcomponents-client/ httpclient/apidocs/index.html

// requires HttpComponents Client 4.*
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(
  ConnRoutePNames.LOCAL_ADDRESS, 
  InetAddress.getByName("10.10.10.10")
);

See: http://hc.apache.org/httpcomponents-client/httpclient/apidocs/index.html

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