I have a problem with simple code as below. I have a loop through span tag on page xxx.pl. During search through second loop i have to navigate to another url in third loop (on same server and same catalog) xxx.pl/yyy and back to previous url xxx.pl. After that i got error massage at
if (el.GetAttribute("className") == "account-block-subtext")
line.
Error massage is:
System.UnauthorizedAccessException
HResult=0x80070005
Message=Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Source=System.Windows.Forms
Any suggestions? In my opinion some operation change el object so i can`t access to it after exiting third loop. Maby session data are lost? Code is below:
foreach (HtmlElement el in doc.GetElementsByTagName("span"))
{
if (el.GetAttribute("className") == "account-block-subtext")
{
foreach (HtmlElement elchild in el.Children)
{
if (elchild.TagName == "A")
{
string alink = "";
try { alink = elchild.GetAttribute("href"); } catch { alink = ""; }
if (alink.Contains("/user/bbb.php"))
{
// klik alink
elchild.InvokeMember("Click");
webBrowser1.Navigate("xxx.pl/yyy");
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
System.Windows.Forms.Application.DoEvents();
System.Threading.Thread.Sleep(500);
}
//Debug.WriteLine(webBrowser1.Url.AbsoluteUri);
foreach (HtmlElement cashmail in doc.GetElementsByTagName("span"))
{
// Debug.WriteLine(">" + cashmail.GetAttribute("className"));
if (cashmail.GetAttribute("className") == "to_read")
{
Debug.WriteLine("cashmail");
}
}
//doc = doc_temp;
}
if (alink.Contains("/shops/pppp.php"))
{
// klik alink
Debug.WriteLine(alink);
}
alink = "";
}
}
}
}
User contributions licensed under CC BY-SA 3.0