首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

用http跟URLconnection盗链

2012-12-24 
用http和URLconnection盗链package com.itcast.refer?import java.io.InputStreamimport java.net.URLi

用http和URLconnection盗链

package com.itcast.refer;

?

import java.io.InputStream;

import java.net.URL;

import java.net.URLConnection;

?

import javax.servlet.http.HttpServlet;

?

public class Client extends HttpServlet {

/*

* 一般,别人比较有特色的网站,都不用许你盗链 所谓盗链就是在别的地方直接访问到特色网站的资源

*?

* 首先用httpwatch获得别人的头字段referer的值 然后把值设置进你的链接,实现带链接的访问

*/

?

public static void main(String[] args) throws Exception {

URL uri = new URL("http://localhost/day4/refer.html");

URLConnection conn = uri.openConnection();

conn.addRequestProperty("referer", "http://localhost/day4/refer.html");// 把防盗链设置进你自己的URL

?

InputStream in = conn.getInputStream();

InputStream fs = in;

byte[] b = new byte[1024];

while ((fs.read(b)) != -1) {

System.out.println(new String(b, 0, b.length));

}

in.close();

fs.close();

}

}


热点排行