zoukankan      html  css  js  c++  java
  • 抓取test

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Net;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;

    namespace SD.Web
    {
    public partial class GetTaoBaoInfo : System.Web.UI.Page
    {
    string html = "";
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!string.IsNullOrEmpty(Request.QueryString["Name"]))
    {

    string url = Request.QueryString["Name"];
    html = GetHttpData("http://cha.mzyz.com/get/cha/?username="+url);
    Regex regex = new Regex(@"<title>(?<value>[\s|\S]*)</title>");
    string title = regex.Match(html).Result("$1");
    Label1.Text = title;


    }
    }
    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();
    //Response.Write(sException);
    }
    catch (Exception e)
    {
    sException = e.ToString();
    //Response.Write(sException);
    }
    finally
    {
    if (oWebRps != null)
    {
    StreamReader oStreamRd = new StreamReader(oWebRps.GetResponseStream(), Encoding.GetEncoding("utf-8"));
    sRslt = oStreamRd.ReadToEnd();
    oStreamRd.Close();
    oWebRps.Close();
    }
    }
    return sRslt;
    }
    }
    }

  • 相关阅读:
    字符串Hash 学习笔记
    P4315 月下“毛景树” 题解
    page
    Equation
    Graph
    配置UOJ数据的正确姿势
    luogu2261余数求和题解--整除分块
    luogu2858奶牛零食题解--区间DP
    luogu1005矩阵取数游戏题解--区间DP
    luogu4677山区建小学题解--区间DP
  • 原文地址:https://www.cnblogs.com/u137578217/p/3470015.html
Copyright © 2011-2022 走看看