linux 爬虫总结 读取poj data

来源:互联网 发布:东方网络 编辑:程序博客网 时间:2024/06/11 21:43
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   idURLConnection 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


原创粉丝点击