获取网址数据Asp.Net

时间:2015-11-11 15:02:15

标签: c# php asp.net

我想做的是根据拉查询链接ID。我能怎么做。任何人都可以帮助我。

sql.php返回表。你可以在下面看到。我希望在将数据放入gridview后逐步阅读。

  

[System.Web.Services.WebMethod]

public static string ekle(string id)
{
    System.Threading.Thread.Sleep(1000);

    string adres = "http://websitename.net/sql.php?id=" + id;
    WebRequest istek = HttpWebRequest.Create(adres);
    WebResponse cevap; 
    cevap = istek.GetResponse(); 
    StreamReader donenBilgiler = new StreamReader(cevap.GetResponseStream()); 
    string gelen = donenBilgiler.ReadToEnd(); //6
    int titleIndexBaslangici = gelen.IndexOf("<td colspan=4 class=\"yaziTracker\">") + 31;
    int titleIndexBitisi = gelen.Substring(titleIndexBaslangici).IndexOf("</td>"); 
    string baslik = gelen.Substring(titleIndexBaslangici, titleIndexBitisi);

    GridView g = new GridView();
    g.CssClass = "mGrid";
    g.ShowHeader = false;
    g.BorderWidth = 2;
    g.CellPadding = 15;
    g.CellSpacing = 15;
    g.GridLines = GridLines.Both;
    g.DataSource = baslik;
    g.DataBind();

    return gelen;
}

0 个答案:

没有答案