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;
    }
    }
    }

  • 相关阅读:
    SSM添加数据后自动获取ID
    EasyUI分页
    JavaScript增强AJAX基础
    高德地图MapAPI地图展示
    项目json代码
    JavaScript 事件机制
    JavaScript event flow
    java和JavaScript的区别
    history of program
    javaScript obj
  • 原文地址:https://www.cnblogs.com/u137578217/p/3470015.html
Copyright © 2011-2022 走看看