資源簡介
利用HtmlAgilityPack可以輕松獲取網頁內容,但是無法獲取動態加載的內容, 通過webBrowser模擬瀏覽器,獲取網頁內容。 大致思路:
1、webBrowser加載網頁 (如有Ajax動態加載分頁的網站,需要配合頁面動作,直到頁面加載完成,如:滾動條操作)
2、加載完成后獲取webBrowser.Document (配合使用webBrowser_DocumentCompleted和Application.DoEvents()) 3、解析網頁內容
代碼片段和文件信息
using?System;
using?System.Windows.Forms;
using?System.Net;
using?System.Text.Regularexpressions;
namespace?InternetSpiderMan
{
????static??class??Classbase
????{
????????#region???public?bool?OutExcel()?導出數據到Execl
????????///?
????????///?導出數據到Execl
????????///?
????????///?
????????///?
????????public?static?bool?OutExcel(DataGridView?paramdatagridview)
????????{
????????????try
????????????{
????????????????if?(paramdatagridview.Rows.Count.Equals(0))
????????????????{
????????????????????return?false;
????????????????}
????????????????Microsoft.Office.Interop.Excel.Application?myExcel?=?new?Microsoft.Office.Interop.Excel.Application();
????????????????myExcel.Application.Workbooks.Add(true);
????????????????myExcel.Visible?=?true;
????????????????for?(int?i?=?0;?i?????????????????{
????????????????????////隱藏列跳過
????????????????????//
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????134144??2012-08-06?21:30??bin\Debug\DLL\HtmlAgilityPack.dll
?????文件????1100392??2007-10-10?09:48??bin\Debug\DLL\Microsoft.Office.Interop.Excel.dll
?????文件?????134144??2012-08-06?21:30??bin\Debug\HtmlAgilityPack.dll
?????文件??????28672??2016-02-01?11:25??bin\Debug\InternetSpiderMan.exe
?????文件????????161??2016-01-29?11:44??bin\Debug\InternetSpiderMan.exe.config
?????文件??????34304??2016-02-01?11:25??bin\Debug\InternetSpiderMan.pdb
?????文件??????22688??2016-02-01?11:23??bin\Debug\InternetSpiderMan.vshost.exe
?????文件?????134144??2012-08-06?21:30??DLL\HtmlAgilityPack.dll
?????文件????1100392??2007-10-10?09:48??DLL\Microsoft.Office.Interop.Excel.dll
?????文件???????1211??2016-02-01?11:25??obj\Debug\InternetSpiderMan.csproj.FileListAbsolute.txt
?????文件???????1077??2016-02-01?11:25??obj\Debug\InternetSpiderMan.csproj.GenerateResource.Cache
?????文件??????28672??2016-02-01?11:25??obj\Debug\InternetSpiderMan.exe
?????文件???????4852??2016-02-01?11:25??obj\Debug\InternetSpiderMan.FormMain.resources
?????文件????????180??2016-02-01?11:25??obj\Debug\InternetSpiderMan.Form_sqw.resources
?????文件??????34304??2016-02-01?11:25??obj\Debug\InternetSpiderMan.pdb
?????文件????????180??2016-02-01?11:25??obj\Debug\InternetSpiderMan.Properties.Resources.resources
?????文件???????1386??2015-02-05?15:17??Properties\AssemblyInfo.cs
?????文件???????2874??2016-01-29?11:44??Properties\Resources.Designer.cs
?????文件???????5612??2015-02-05?15:17??Properties\Resources.resx
?????文件???????1117??2016-01-29?11:44??Properties\Settings.Designer.cs
?????文件????????249??2015-02-05?15:17??Properties\Settings.settings
?????文件????????161??2016-01-29?11:44??app.config
?????文件???????5098??2016-01-28?14:49??Classba
?????文件???????7939??2016-02-01?11:03??Form_sqw.cs
?????文件??????15398??2016-02-01?11:03??Form_sqw.Designer.cs
?????文件???????6944??2016-02-01?11:03??Form_sqw.resx
?????文件????????692??2016-02-01?11:23??FormMain.cs
?????文件???????3352??2016-02-01?11:04??FormMain.Designer.cs
?????文件??????12549??2016-02-01?11:04??FormMain.resx
?????文件?????290304??2012-08-06?21:30??HtmlAgilityPack.pdb
............此處省略14個文件信息
- 上一篇:基于RS232通訊的電池管理系統源碼
- 下一篇:電動汽車動力電池組管理系統設計
評論
共有 條評論