public string GetHttpData(string Url)
{
string sException=null;
string sRslt=null;
WebResponse oWebRps=null;
WebRequest oWebRqst=WebRequest.Create(Url);
oWebRqst.Timeout=50000;
try
{
oWebRps=oWebRqst.GetResponse();
}
catch(WebException e)
{
sException=e.Message.ToString();
EYResponse.Write(sException);
}
catch(Exception e)
{
sException=e.ToString();
EYResponse.Write(sException);
}
finally
{
if(oWebRps!=null)
{
StreamReader oStreamRd=new StreamReader(oWebRps.GetResponseStream(),Encoding.GetEncoding("GB2312"));
sRslt=oStreamRd.ReadToEnd();
oStreamRd.Close();
oWebRps.Close();
}
}
return sRslt;
}
如果内容是这样有规律的话
你可以用 substring 来做截取 截取 ">"到"<"的内容就可以了
实现代码如下:
public static String Html2Text(String inputString){
String htmlStr = inputString; //含html标签的字符串
String textStr ="";
java.util.regex.Pattern p_script;
java.util.regex.Matcher m_script;
java.util.regex.Pattern p_style;
java.util.regex.Matcher m_style;
java.util.regex.Pattern p_html;
java.util.regex.Matcher m_html;
try{
String regEx_script = "<[\\s]*?script[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?script[\\s]*?>"; //定义script的正则表达式{或