linux 爬虫总结 读取poj data


import java.net.*;
import java.io.*;

public class urlconnection
{
public static void main(String[] args)
{
StringBuffer document = new StringBuffer();
try
{
URL url = new URL("http://poj.org/problem?id=1011");//poj   id
URLConnection conn = url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null)
document.append(line + "\n");
reader.close();
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}

String begin = document.toString().split("Sample Input</p><pre class=")[1];

begin.replaceAll("\"", "o");
begin = begin.substring(6);
String end = begin.split(">Sample Output</p>")[0];//</pre><p class=
end = end.split("</pre><p class=")[0];
System.out.println(end);
}
}

 




http://www.blogjava.net/Martin-Liu-Hai-Shi/articles/214615.html

java 实现http://usejava.iteye.com/blog/724177

python:简单有效实现http://www.lovelucy.info/python-crawl-pages.html



http://blog.csdn.net/ithomer/article/details/7626929这篇博客可以设置代理进行爬虫下载

知识拓展:

在国内,由于某种原因一般难以直接访问国外某些敏感网站,需要通过 VPN 或 代理服务器才能访问

如果校园网和教育网有IPv6,则可以通过sixxs.org免费代理访问facebook、twitter、六维空间等网站


其实,除了VPN 和 IPv6+sixxs.org代理方式外,普通用户还是有其它途径访问到国外网站

下面介绍两个著名的免费代理网站:

freeproxylists.net(全球数十个国家的免费代理,每日都更新)

xroxy.com(通过设置端口类型、代理类型、国家名称进行筛选)


curl 项目实例

使用curl + freeproxylists.net免费代理,实现了全球12国家google play游戏排名的网页抓取以及趋势图查询(抓取网页模块全部使用Shell编写,核心代码约1000行)

游戏排名趋势图请见我先前的博客:JFreeChart项目实例


java爬虫例子:http://blog.csdn.net/ithomer/article/details/6916506

linux shell:http://blog.csdn.net/ithomer/article/details/7635301


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值