var defaultCondiction = Ext.create('Ext.form.Panel', {
autoScroll: true,
bodyCls: 'searchFormPanel',
style: 'top:5px',
flex: 20,
id: 'defaultCondiction',
border: false,
layout: {
type: 'table',
columns: 4,
tableAttrs: {
style: "border:0px solid #bbb;border-collapse:collapse;width:'100%'"
},
tdAttrs: {
style: "border:0px solid #ccc;border-collapse:collapse;padding-left:30px;"
}
},
items: [
{
xtype: 'textfield',
hidden: true,
name: 'tableModelName',
value: 'TFaultMainForm'
},
{
xtype: 'textfield',
fieldLabel: '工单编号:',
labelWidth: 60,
width: itemWidth,
name: 'bizMap[woCode]',
withBorder: true
},
{
xtype: 'textfield',
fieldLabel: '工单主题:',
labelWidth: 60,
width: itemWidth,
name: 'bizMap[subject]',
value: null,
withBorder: true
} ,
{
xtype: 'date',
fieldLabel: '申告时间:',
name: 'bizMap[processCreateTimeStart]',
id: 'createTimeStart',
format: 'Y-m-d H:i:s',
labelWidth: 60,
width: itemWidth,
withBorder: true,
editable: false
},
{
xtype: 'date',
fieldLabel: '至:',
labelWidth: 60,
width: itemWidth,
name: 'bizMap[processCreateTimeEnd]',
id: 'createTimeEnd',
format: 'Y-m-d H:i:s',
withBorder: true,
editable: false
}
]
});
我现在需要用WINFORM程序抓取一个网页的表单信息,可是用Webbrowser抓取的源码都是extjs的脚本,已经用了网上的办法,设置TIMER等待网页加载5S后再获取源码,可还是依旧,江湖救急请各位大神指教,如何获取该页面的html源码?
1 while (wb_main.ReadyState != WebBrowserReadyState.Complete) 2 { 3 Application.DoEvents(); 4 } 5 6 System.Timers.Timer timer = new System.Timers.Timer(); 7 8 var isComplete = false; 9 10 timer.Elapsed += new System.Timers.ElapsedEventHandler((sender, e) => 11 { 12 //加载完毕 13 isComplete = true; 14 15 timer.Stop(); 16 }); 17 18 timer.Interval = 1000 * 10; 19 20 timer.Start(); 21 22 //继续等待 5s,等待js加载完 23 while (!isComplete) 24 Application.DoEvents(); 25 26 var htmldocument = (mshtml.HTMLDocument)wb_main.Document.DomDocument; 27 28 string gethtml = htmldocument.documentElement.outerHTML; 29 30 //写入文件 31 using (StreamWriter sw = new StreamWriter(Environment.CurrentDirectory + "//1.html")) 32 { 33 sw.WriteLine(gethtml); 34 }
这是webbrowser获取网页的源码
你获取html的语句不是应该放在timer的绑定函数中吗?你用个while把主线程占了,不管等多久webbrowser都加载不出来的吧。