用FireBug发现是新增加了一堆html代码
由于这个层上有个关闭按钮我需要去操作
通过GetElementById无法获得这个按钮
求教
4 个解决方案
#1
顶一下
#2
继续顶一下,有高手在吗
#3
我也需要这个功能,知道了通知我一下哈
研究一下Firebug 和 IE Inspector..
研究一下Firebug 和 IE Inspector..
#4
刚帮忙解决了一个类似的问题:
http://topic.csdn.net/u/20120820/10/f2f21a45-5395-4cef-8d08-34e2022be8f1.html
http://topic.csdn.net/u/20120820/10/f2f21a45-5395-4cef-8d08-34e2022be8f1.html
System.Timers.Timer timer = null;
private void Form1_Load(object sender, EventArgs e)
{
string url = "http://stock.finance.sina.com.cn/hkstock/finance/01398.html";
webBrowser1.Navigate(url);
timer = new System.Timers.Timer(1000);
timer.AutoReset = false;
timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
}
public delegate void GetDataHandler();
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
Invoke(new GetDataHandler(getData));
timer.Start();
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//避免webbroswer.DocumentCompleted被多次引发
if ((e.Url != webBrowser1.Url) || (webBrowser1.ReadyState != WebBrowserReadyState.Complete))
return;
//下面写你要在页面加载完毕后执行的代码。
getSelectedCtrl();
}
private void getSelectedCtrl()
{
System.Windows.Forms.HtmlDocument doc = this.webBrowser1.Document;
System.Windows.Forms.HtmlElementCollection selectCtrls = doc.GetElementsByTagName("select");
string attName;
foreach (System.Windows.Forms.HtmlElement selectCtrl in selectCtrls)
{
attName = selectCtrl.GetAttribute("table");
if (attName.Equals("tableGetBalanceSheet"))//如果table属性是资产负债表的话,模拟引发“报表类型”的选择控件
{
foreach(HtmlElement option in selectCtrl.Children)
{
if(option.GetAttribute("value") == "zero")
{
option.SetAttribute("selected", "selected");
break;
}
}
selectCtrl.RaiseEvent("onchange");
timer.Start();
return;
}
}
}
#1
顶一下
#2
继续顶一下,有高手在吗
#3
我也需要这个功能,知道了通知我一下哈
研究一下Firebug 和 IE Inspector..
研究一下Firebug 和 IE Inspector..
#4
刚帮忙解决了一个类似的问题:
http://topic.csdn.net/u/20120820/10/f2f21a45-5395-4cef-8d08-34e2022be8f1.html
http://topic.csdn.net/u/20120820/10/f2f21a45-5395-4cef-8d08-34e2022be8f1.html
System.Timers.Timer timer = null;
private void Form1_Load(object sender, EventArgs e)
{
string url = "http://stock.finance.sina.com.cn/hkstock/finance/01398.html";
webBrowser1.Navigate(url);
timer = new System.Timers.Timer(1000);
timer.AutoReset = false;
timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
}
public delegate void GetDataHandler();
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
Invoke(new GetDataHandler(getData));
timer.Start();
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//避免webbroswer.DocumentCompleted被多次引发
if ((e.Url != webBrowser1.Url) || (webBrowser1.ReadyState != WebBrowserReadyState.Complete))
return;
//下面写你要在页面加载完毕后执行的代码。
getSelectedCtrl();
}
private void getSelectedCtrl()
{
System.Windows.Forms.HtmlDocument doc = this.webBrowser1.Document;
System.Windows.Forms.HtmlElementCollection selectCtrls = doc.GetElementsByTagName("select");
string attName;
foreach (System.Windows.Forms.HtmlElement selectCtrl in selectCtrls)
{
attName = selectCtrl.GetAttribute("table");
if (attName.Equals("tableGetBalanceSheet"))//如果table属性是资产负债表的话,模拟引发“报表类型”的选择控件
{
foreach(HtmlElement option in selectCtrl.Children)
{
if(option.GetAttribute("value") == "zero")
{
option.SetAttribute("selected", "selected");
break;
}
}
selectCtrl.RaiseEvent("onchange");
timer.Start();
return;
}
}
}