private void runBrowserThread(string url)
{
try
{
var th = new Thread(() =>
{
var br = new WebBrowser();
br.DocumentCompleted += browser_DocumentCompleted;
br.Navigate(url);
Application.Run();
});
th.SetApartmentState(ApartmentState.STA);
th.Start();
}
catch (Exception ex)
{
}
}
#region - Browser Event -
void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
string Downloaddata = string.Empty;
HtmlDocument doc = ((WebBrowser)sender).Document;
HtmlElementCollection textboxes = doc.GetElementsByTagName("textarea");
foreach (HtmlElement textbox in textboxes)
{
Downloaddata = textbox.InnerText;
Downloaddata = Downloaddata + "";
}
File.WriteAllText("Give your path" + "file Name", Downloaddata);
}
catch (Exception ex)
{
}
}
{
try
{
var th = new Thread(() =>
{
var br = new WebBrowser();
br.DocumentCompleted += browser_DocumentCompleted;
br.Navigate(url);
Application.Run();
});
th.SetApartmentState(ApartmentState.STA);
th.Start();
}
catch (Exception ex)
{
}
}
#region - Browser Event -
void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
string Downloaddata = string.Empty;
HtmlDocument doc = ((WebBrowser)sender).Document;
HtmlElementCollection textboxes = doc.GetElementsByTagName("textarea");
foreach (HtmlElement textbox in textboxes)
{
Downloaddata = textbox.InnerText;
Downloaddata = Downloaddata + "";
}
File.WriteAllText("Give your path" + "file Name", Downloaddata);
}
catch (Exception ex)
{
}
}
No comments:
Post a Comment