简体   繁体   English

如何从Java中的CURL响应中删除HTTP标头

[英]How to remove HTTP headers from CURL response in Java

I need to remove HTTP headers from the parsed web pages in Java. 我需要从Java解析的网页中删除HTTP标头。

    HTTP/1.1 404 Not Found
    Date: Wed, 28 Oct 2009 14:10:05 GMT
    Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
    Last-Modified: Tue, 02 Jun 2009 17:40:52 GMT
    ETag: "18ac11-d16-46b610b465100"
    Accept-Ranges: bytes
    Content-Length: 3350
    Connection: close
    Content-Type: text/html
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

As shown above, first few lines are http headers. 如上所示,前几行是http标头。 I need to get rid of them to process parsed pages, but then, I'm not sure on how to do it since headers vary in length and in contents. 我需要摆脱它们来处理已解析的页面,但是由于标题的长度和内容不同,我不确定如何执行。

Could anyone please help me with this? 有人可以帮我吗?

您可以简单地获取例如<html索引并对该字符串进行子字符串化。

text.substring(text.indexOf("<html"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM