它是一种删除或隐藏请求标头中的http引用信息的方法吗?我想删除使用javascript python或django中的脚本从我的网站转到其他网站的用户的http引用信息
例:
Host slogout.espncricinfo.com
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Referer http://slogout.espncricinfo.com/index.php?page=index&level=login
Run Code Online (Sandbox Code Playgroud) 我正在制作一个爬虫,并且需要从流中获取数据,无论它是否为200.CURL正在这样做,以及任何标准浏览器.
以下实际上不会获取请求的内容,即使有一些,也会引发http错误状态代码的异常.我想要输出,是否有办法?我更喜欢使用这个库,因为它实际上会执行持久连接,这对于我正在进行的爬行类型来说是完美的.
package test;
import java.net.*;
import java.io.*;
public class Test {
public static void main(String[] args) {
try {
URL url = new URL("http://github.com/XXXXXXXXXXXXXX");
URLConnection connection = url.openConnection();
DataInputStream inStream = new DataInputStream(connection.getInputStream());
String inputLine;
while ((inputLine = inStream.readLine()) != null) {
System.out.println(inputLine);
}
inStream.close();
} catch (MalformedURLException me) {
System.err.println("MalformedURLException: " + me);
} catch (IOException ioe) {
System.err.println("IOException: " + ioe);
}
}
}
Run Code Online (Sandbox Code Playgroud)
工作,谢谢:这是我想出的 - 就像一个粗略的概念证明:
import java.net.*;
import java.io.*;
public class Test {
public static …Run Code Online (Sandbox Code Playgroud)