1、该网站的ppt链接全部都在页面上,用正则手动提取所有链接,放在指定位置的,以txt形式保存,格式如下

2、写个java文件处理一下,如下:

 package platform;

 import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map; import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient; public class TestQConDownload { public static void main(String[] args) {
BufferedReader bufferedReader;
String lineTxt = null;
String title="1";
String url="";
try {
//读文件
bufferedReader = readTxtFile("E:\\test\\downinfo.txt");
//循环遍历每行
while((lineTxt = bufferedReader.readLine()) != null){
if(lineTxt.startsWith("【标题】")){
title = lineTxt.substring(4).replaceAll(":", "");
System.out.println(title);
}
if(lineTxt.startsWith("【下载地址】")){
url= lineTxt.substring(6);
//获取跳转后的地址
url = getRedirectLocation(url);
System.out.println(url);
//下载到指定位置
downloadFile(url, "E:\\test\\download\\"+title+".pdf");
}
}
bufferedReader.close();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} } public static String getRedirectLocation(String url) throws ClientProtocolException, IOException {
String SEND_MESSAGE_URL = url;
Map<String, Object> params = new HashMap<String, Object>();
HttpPost get = new HttpPost(SEND_MESSAGE_URL);
get.setHeader("Cookie", "dx_un=%E5%B9%B4%E8%BD%BB%E7%9A%84%E7%96%AF%E5%AD%90; dx_avatar=http%3A%2F%2F7xil0e.com1.z0.glb.clouddn.com%2Fuser_580d84f25ea61.png; dx_token=0c6b719ffff50f3746b64f058cb4e719");
get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
get.setHeader("Accept-Encoding", "zh-CN,zh;q=0.8");
get.setHeader("Connection", "keep-alive");
get.setHeader("Host", "ppt.geekbang.org");
get.setHeader("Referer", "http://2016.qconshanghai.com/schedule");
get.setHeader("Upgrade-Insecure-Requests", "1");
get.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36"); // 设置编码
HttpResponse re = new DefaultHttpClient().execute(get);
/*if (re.getStatusLine().getStatusCode() == 200) {// 如果状态码为200,就是正常返回
String result = EntityUtils.toString(re.getEntity());
System.out.println(result);
}*/
String location = re.getFirstHeader("Location").getValue();
get.releaseConnection();
return location;
} /**
* 下载远程文件并保存到本地
* @param remoteFilePath 远程文件路径
* @param localFilePath 本地文件路径
*/
public static void downloadFile(String remoteFilePath, String localFilePath)
{
URL urlfile = null;
HttpURLConnection httpUrl = null;
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
File f = new File(localFilePath);
try
{
urlfile = new URL(remoteFilePath);
httpUrl = (HttpURLConnection)urlfile.openConnection();
httpUrl.connect();
bis = new BufferedInputStream(httpUrl.getInputStream());
bos = new BufferedOutputStream(new FileOutputStream(f));
int len = 2048;
byte[] b = new byte[len];
while ((len = bis.read(b)) != -1)
{
bos.write(b, 0, len);
}
bos.flush();
bis.close();
httpUrl.disconnect();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
bis.close();
bos.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
} public static BufferedReader readTxtFile(String filePath) throws UnsupportedEncodingException, FileNotFoundException{
String encoding="UTF-8";
File file=new File(filePath);
InputStreamReader read = new InputStreamReader(
new FileInputStream(file),encoding);//考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
return bufferedReader;
}
}

通过自己技能把某个网站的ppt全部下载下来的过程的更多相关文章

  1. 20款高质量的 HTML5 网站模板【免费下载】

    下面的列表集合了20款高质量的免费 HTML5 网站模板,这些专业的模板能够让你的网站吸引很多的访客.这些免费的 HTML5 模板虽然不是响应式的,不过都很实用.赶紧来看看. 您可能感兴趣的相关文章 ...

  2. 20款免费的 PSD 网站模板【免费下载】

    如果你的新项目预算很低,那么免费网站模板对你来说是一个很好的解决方案.有很多的预先设计的网站模板 PSD 素材可以使用和自由定制.在这里,你会发现可供下载的超级棒的免费网站模板.你可以使用它们来创建自 ...

  3. 使用Nginx和Logstash以及kafka来实现网站日志采集的详细步骤和过程

    使用Nginx和Logstash以及kafka来实现网站日志采集的详细步骤和过程 先列出来总体启动流程: (1)启动zookeeper集群(hadoop01.hadoop02和hadoop03这3台机 ...

  4. 深圳安全研讨会圆满结束,PPT共享下载

    深圳安全研讨会圆满结束,PPT共享下载: http://pan.baidu.com/s/19XFtO

  5. PPT资料下载 - 问题驱动的软件测试设计:强化测试用例设计

    测试用例设计是整个软件测试过程中非常重要的测试活动,需求规格说明是测试人员开展测试设计的主要参考输入.而在测试实践中基于需求规格说明得到的测试用例,在测试覆盖率.测试效率.测试有效性和测试质量等方面的 ...

  6. 广州亿能自动化测试沙龙 - 自动化测试管理平台设计 [ 沙龙PPT免费下载 ]

    广州亿能自动化测试沙龙 - 自动化测试管理平台设计 [ 沙龙PPT免费下载 ] http://automationqa.com/forum.php?mod=viewthread&tid=244 ...

  7. 无比强大!Python抓取cssmoban网站的模版并下载

    Python实现抓取http://www.cssmoban.com/cssthemes网站的模版并下载 实现代码 # -*- coding: utf-8 -*- import urlparse imp ...

  8. PPT——一个有情怀的免费PPT模板下载网站!“优品PPT”

    http://www.ypppt.com/ PS:再推荐一款免费PPT下载网站 https://www.v5ppt.com/ppt-5-42-1.html

  9. Apsara Clouder云计算专项技能认证:网站建设-简单动态网站搭建

    一.课程介绍 1.课程目标 了解静态网站和动态网站的区别 掌握动态网站的不同实现方式 在阿里云上如何搭建 wordPress网站以及 wordPress 网站的管理和优化 二.网站搭建的类型 1.网站 ...

随机推荐

  1. iOS设计模式之命令模式

    命令模式 基本理解 命令模式(Command),将一个请求封装为一个对象,从而使你可用不同的请求对客户端进行参数化:对请求队列或记录请求日志,以及支持客可撤离的操作. 苹果的Target-Action ...

  2. SSH整合简述一

    1.web.xml中配置 struts2过滤器 <filter> <filter-name>struts2</filter-name> <filter-cla ...

  3. LeetCode 7 Reverse Integer(反转数字)

    题目来源:https://leetcode.com/problems/reverse-integer/ Reverse digits of an integer. Example1: x = 123, ...

  4. 纪录JVM内存模型内容

    声明:本内容是博主在牛客网上看到的网友发表的答案,因为感觉总结的比较好,所以摘抄过来供大家学习. 内容: 大多数 JVM 将内存区域划分为 Method Area(Non-Heap)(方法区) ,He ...

  5. [QualityCenter]设置工作流脚本-新建缺陷时描述字段模板设置

    需求:实现新建缺陷时,描述模板自动生成填写模板. 在脚本编辑器找到Defects_Bug_New函数,然后填写以下代码: Sub Defects_Bug_New    On Error Resume ...

  6. python 把数据 json格式输出

    有个要求需要在python的标准输出时候显示json格式数据,如果缩进显示查看数据效果会很好,这里使用json的包会有很多操作 import json date = {u'versions': [{u ...

  7. Oracle-创建服务器参数文件

    允许使用传统的init.ora或SPFILE作为配置文件.但是建议所有数据库创建和使用一个SPFILE.可以从init.ora创建SPFILE SQL> CREATE spfile FROM p ...

  8. 使用MongoDB C#官方驱动操作MongoDB

    想要在C#中使用MongoDB,首先得要有个MongoDB支持的C#版的驱动.C#版的驱动有很多种,如官方提供的,samus. 实现思路大都类似.这里我们先用官方提供的mongo-csharp-dri ...

  9. VirtualBox: Effective UID is not root (euid=1000 egid=100 uid=1000 gid=100)

    桌面上运行virtualbox出错: The virtual machine 'xp' has terminated unexpectedly during startup with exit cod ...

  10. hdu Flow Problem (最大流 裸题)

    最大流裸题,贴下模版 view code#include <iostream> #include <cstdio> #include <cstring> #incl ...