我嘗試這樣做,我想,該網站的源內容將下載到的字符串:如何將網站內容下載到字符串?
public partial class Form1 : Form
{
WebClient client;
string url;
string[] Search(string SearchParameter);
public Form1()
{
InitializeComponent();
url = "http://chatroll.com/rotternet";
client = new WebClient();
webBrowser1.Navigate("http://chatroll.com/rotternet");
}
private void Form1_Load(object sender, EventArgs e)
{
}
static void DownloadDataCompleted(object sender,
DownloadDataCompletedEventArgs e)
{
}
public string SearchForText(string SearchParameter)
{
client.DownloadDataCompleted += DownloadDataCompleted;
client.DownloadDataAsync(new Uri(url));
return SearchParameter;
}
我要使用Web客戶端和downloaddataasync並在年底有一個字符串的網站源內容。
爲什麼你同時擁有'webBrowser1'和'client'? – Oded 2012-08-09 20:03:02
「我想起訴WebClient ..」:) :) – 2012-08-09 20:03:30
網站和網頁有區別,在這種情況下非常重要。您正在下載單個頁面。它不會有任何鏈接的資源(圖像,CSS,JavaScript,幀),也不會下載任何鏈接的頁面。 – Sklivvz 2012-08-09 20:04:59