是否有任何方法从第1-5级执行urlfilter和从5开始执行不同的urlfilter。我需要提取的pdf文件,这将只在一个给定的水平(只是为了实验)。
pdf文件将以二进制格式存储在爬行/段文件夹中。我想提取这些pdf文件,并将所有存储在一个文件夹。我已经能够编写一个java程序来识别一个pdf文件。我不知道如何制作一个pdf文件的内容与相同的字体,页面#,图像等。
这只会识别pdf档案:
String uri = "/usr/local/nutch/framework/apache-nutch-1.6/merged572/20130407131335";
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), conf);
Path path = new Path(uri, Content.DIR_NAME + "/part-00000/data");
SequenceFile.Reader reader = null;
try {
reader = new SequenceFile.Reader(fs, path, conf);
Text key = new Text();
Content content = new Content();
while (reader.next(key, content)) {
String contentType = content.getContentType();
if (contentType.equalsIgnoreCase("application/pdf")) {
//System.out.write( content.getContent(), 0, content.getContent().length );
System.out.println(key);
}
}
reader.close();
}
finally {
fs.close();
}发布于 2013-04-09 22:20:09
content.getContent()将以字节为单位返回内容。
只需使用BufferedOutputStream将字节写入文件并将其保存为pdf
https://stackoverflow.com/questions/15853628
复制相似问题