将整个html内容保存到指定文件

package parser;

 

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.FileWriter;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.net.MalformedURLException;

import java.net.URL;

 

/**

 * 基本能实现网页抓取,不过要手动输入URL 将整个html内容保存到指定文件

 *

 *@author chenguoyong

 *

 */

public class ScrubSelectedWeb {

       privatefinal static String CRLF = System.getProperty("line.separator");

 

       /**

        * @param args

        */

       publicstatic void main(String[] args) {

              try{

                     URLur = newURL("http://10.249.187.199:8083/injs100/");

                     InputStreaminstr = ur.openStream();

                     Strings, str;

                     BufferedReaderin = new BufferedReader(new InputStreamReader(instr));

                     StringBuffersb = new StringBuffer();

                     BufferedWriterout = new BufferedWriter(new FileWriter(

                                   "D:/outPut.txt"));

                     while((s = in.readLine()) != null) {

                            sb.append(s+ CRLF);

                     }

                     System.out.println(sb);

                     str= new String(sb);

                     out.write(str);

                     out.close();

                     in.close();

              }catch (MalformedURLException e) {

                     e.printStackTrace();

              }catch (IOException e) {

                     e.printStackTrace();

              }

 

       }

 

}

基本能实现网页抓取,不过要手动输入URL,此外没有重构。只是一个简单的思路。

 

1.1    搜索引擎优化的主要工作目的链接

http://c.tieba.baidu.com/p/3342634576
http://c.tieba.baidu.com/p/3342638170
http://c.tieba.baidu.com/p/3342639335
http://c.tieba.baidu.com/p/3342640390
http://c.tieba.baidu.com/p/3342641391
http://c.tieba.baidu.com/p/3342642100
http://c.tieba.baidu.com/p/3342642969
http://c.tieba.baidu.com/p/3342643615
http://c.tieba.baidu.com/p/3342626071
http://c.tieba.baidu.com/p/3342627944
http://c.tieba.baidu.com/p/3342628822
http://c.tieba.baidu.com/p/3342630123
http://c.tieba.baidu.com/p/3342622068
http://c.tieba.baidu.com/p/3342927900
http://c.tieba.baidu.com/p/3342926512
http://c.tieba.baidu.com/p/3342925162
http://c.tieba.baidu.com/p/3342923767
http://c.tieba.baidu.com/p/3342922016
http://c.tieba.baidu.com/p/3342920689
http://c.tieba.baidu.com/p/3342919727
http://c.tieba.baidu.com/p/3342937294
http://c.tieba.baidu.com/p/3342936126
http://c.tieba.baidu.com/p/3342934603
http://c.tieba.baidu.com/p/3342933119
http://c.tieba.baidu.com/p/3342931972
http://c.tieba.baidu.com/p/3342930889
http://c.tieba.baidu.com/p/3342939984
http://c.tieba.baidu.com/p/3342941804
http://c.tieba.baidu.com/p/3342447144
http://c.tieba.baidu.com/p/3342763942
http://c.tieba.baidu.com/p/3342876435
http://c.tieba.baidu.com/p/3342886405
http://c.tieba.baidu.com/p/3342890062
http://c.tieba.baidu.com/p/3342895055
http://c.tieba.baidu.com/p/3342900245
http://c.tieba.baidu.com/p/3342903181
http://c.tieba.baidu.com/p/3342905524
http://c.tieba.baidu.com/p/3342907667
http://c.tieba.baidu.com/p/3342916958
http://c.tieba.baidu.com/p/3342915428
http://c.tieba.baidu.com/p/3342912855
http://c.tieba.baidu.com/p/3342911391
http://c.tieba.baidu.com/p/3342910383
http://c.tieba.baidu.com/p/3342433437
http://c.tieba.baidu.com/p/3342432336
http://c.tieba.baidu.com/p/3342468956
http://c.tieba.baidu.com/p/3342466401
http://c.tieba.baidu.com/p/3342463933
http://c.tieba.baidu.com/p/3342462707
http://c.tieba.baidu.com/p/3342458123
http://c.tieba.baidu.com/p/3342456889
http://c.tieba.baidu.com/p/3342454243
http://c.tieba.baidu.com/p/3342451654
http://c.tieba.baidu.com/p/3342605501
http://c.tieba.baidu.com/p/3342754421
http://c.tieba.baidu.com/p/3342744247
http://c.tieba.baidu.com/p/3342759218
http://c.tieba.baidu.com/p/3342419773
http://c.tieba.baidu.com/p/3342418020
http://c.tieba.baidu.com/p/3342416164
http://c.tieba.baidu.com/p/3342415006
http://c.tieba.baidu.com/p/3342411989
http://c.tieba.baidu.com/p/3342410875
http://c.tieba.baidu.com/p/3342409515
http://c.tieba.baidu.com/p/3342408001
http://c.tieba.baidu.com/p/3342406598
http://c.tieba.baidu.com/p/3342404479
http://c.tieba.baidu.com/p/3342403251
http://c.tieba.baidu.com/p/3342447922
http://c.tieba.baidu.com/p/3342437057
http://c.tieba.baidu.com/p/3342436336
http://c.tieba.baidu.com/p/3342434835
http://c.tieba.baidu.com/p/3341697133
http://c.tieba.baidu.com/p/3341756628
http://c.tieba.baidu.com/p/3341752970
http://c.tieba.baidu.com/p/3341750395
http://c.tieba.baidu.com/p/3341747669
http://c.tieba.baidu.com/p/3341744002
http://c.tieba.baidu.com/p/3341736529
http://c.tieba.baidu.com/p/3341779270
http://c.tieba.baidu.com/p/3341773201
http://c.tieba.baidu.com/p/3341769538
http://c.tieba.baidu.com/p/3341767543
http://c.tieba.baidu.com/p/3341775115
http://c.tieba.baidu.com/p/3342422685
http://c.tieba.baidu.com/p/3342421153
http://c.tieba.baidu.com/p/3341190466
http://c.tieba.baidu.com/p/3341685057
http://c.tieba.baidu.com/p/3341683412
http://c.tieba.baidu.com/p/3341681112
http://c.tieba.baidu.com/p/3341671961
http://c.tieba.baidu.com/p/3341667527
http://c.tieba.baidu.com/p/3341663766
http://c.tieba.baidu.com/p/3341661614
http://c.tieba.baidu.com/p/3341659947
http://c.tieba.baidu.com/p/3341718220
http://c.tieba.baidu.com/p/3341715564
http://c.tieba.baidu.com/p/3341708567
http://c.tieba.baidu.com/p/3341707394
http://c.tieba.baidu.com/p/3341704040
http://c.tieba.baidu.com/p/3341699920
http://c.tieba.baidu.com/p/3341187359
http://c.tieba.baidu.com/p/3341185502
http://c.tieba.baidu.com/p/3341183128
http://c.tieba.baidu.com/p/3341181702
http://c.tieba.baidu.com/p/3341180390
http://c.tieba.baidu.com/p/3341179186
http://c.tieba.baidu.com/p/3341654717
http://c.tieba.baidu.com/p/3341651493
http://c.tieba.baidu.com/p/3341649244
http://c.tieba.baidu.com/p/3341648028
http://c.tieba.baidu.com/p/3341646671
http://c.tieba.baidu.com/p/3341643724
http://c.tieba.baidu.com/p/3341641500
http://c.tieba.baidu.com/p/3341638968
http://c.tieba.baidu.com/p/3341636346
http://c.tieba.baidu.com/p/3341174970
http://c.tieba.baidu.com/p/3341173834
http://c.tieba.baidu.com/p/3341171863
http://c.tieba.baidu.com/p/3341170765
http://c.tieba.baidu.com/p/3341169577
http://c.tieba.baidu.com/p/3341167920
http://c.tieba.baidu.com/p/3340791254
http://c.tieba.baidu.com/p/3340787021
http://c.tieba.baidu.com/p/3340785027
http://c.tieba.baidu.com/p/3340783435

http://c.tieba.baidu.com/p/3340672363
http://c.tieba.baidu.com/p/3340665440
http://c.tieba.baidu.com/p/3340660646
http://c.tieba.baidu.com/p/3340655904
http://c.tieba.baidu.com/p/3340697881
http://c.tieba.baidu.com/p/3340692422
http://c.tieba.baidu.com/p/3340779409
http://c.tieba.baidu.com/p/3340597197
http://c.tieba.baidu.com/p/3340595168
http://c.tieba.baidu.com/p/3340593091
http://c.tieba.baidu.com/p/3340590875
http://c.tieba.baidu.com/p/3340590600
http://c.tieba.baidu.com/p/3340587099
http://c.tieba.baidu.com/p/3340585530
http://c.tieba.baidu.com/p/3340582392
http://c.tieba.baidu.com/p/3340648445
http://c.tieba.baidu.com/p/3340646207
http://c.tieba.baidu.com/p/3340641760
http://c.tieba.baidu.com/p/3340634654
http://c.tieba.baidu.com/p/3340631307
http://c.tieba.baidu.com/p/3340630193
http://c.tieba.baidu.com/p/3340628059
http://c.tieba.baidu.com/p/3340681193
http://c.tieba.baidu.com/p/3340678842
http://c.tieba.baidu.com/p/3340676775
http://c.tieba.baidu.com/p/3332560593
http://c.tieba.baidu.com/p/3342556760
http://c.tieba.baidu.com/p/3342795228
http://c.tieba.baidu.com/p/3342738155
http://c.tieba.baidu.com/p/3342553617
http://c.tieba.baidu.com/p/3342504444
http://c.tieba.baidu.com/p/3342506688
http://c.tieba.baidu.com/p/3342503298
http://c.tieba.baidu.com/p/3338388539
http://c.tieba.baidu.com/p/3342553617
http://c.tieba.baidu.com/p/3342798515
http://c.tieba.baidu.com/p/3342789571
http://c.tieba.baidu.com/p/3342549483
http://c.tieba.baidu.com/p/3342501680
http://c.tieba.baidu.com/p/3342848917
http://c.tieba.baidu.com/p/3342851128
http://c.tieba.baidu.com/p/3343072625



 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。