資源簡介
C#C/S 寫的 爬蟲接口,支持接口,網頁,文件資源下載等數據下載!
具體可參考博客地址:http://blog.csdn.net/qq237183141/article/details/79208909

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?System.IO;
using?System.Threading;
using?System.Net;
using?AngleSharp;
namespace?DataCatch
{
????public?partial?class?FrmMain?:?Form
????{
????????public?FrmMain()
????????{
????????????InitializeComponent();
????????}
????????HttpHelper?helper?=?new?HttpHelper();
????????Thread?dThread;//下載線程
????????/*-----------------------------------------------------第-部分抓取接口數據------------------------------------------------------------------*/
????????///?
????????///?接口文件下載
????????///?
????????///?
????????///?
????????private?void?btnIStart_Click(object?sender?EventArgs?e)
????????{
????????????string?url?=?txtIUrl.Text.Trim();
????????????if?(string.IsNullOrEmpty(url))
????????????{
????????????????MessageBox.Show(“url參數不能為空!“);
????????????????return;
????????????}
????????????string?strType?=?cmbIType.SelectedItem.ToString();
????????????if?(string.IsNullOrEmpty(strType))
????????????{
????????????????MessageBox.Show(“請選擇請求類型!“);
????????????????return;
????????????}
????????????string?myCookie?=?txtCookie.Text.Trim();
????????????string?strData?=?txtIPara.Text.Trim();
????????????if?(strType?==?“GET“)
????????????????txtResult.Text?=?helper.HttpGetRequest(url?myCookie);
????????????else?if?(strType?==?“POST“)
????????????????txtResult.Text?=?helper.HttpPostRequest(url?strData?myCookie);
????????}
????????/*-----------------------------------------------------第三部分下載文件------------------------------------------------------------------*/
????????///?
????????///?文件下載
????????///?
????????///?
????????///?
????????private?void?btnFStart_Click(object?sender?EventArgs?e)
????????{
????????????string?url?=?txtFUrl.Text.Trim();
????????????if?(string.IsNullOrEmpty(url))
????????????{
????????????????MessageBox.Show(“url參數不能為空!“);
????????????????return;
????????????}
????????????string?path?=?txtSavePath.Text.Trim();
????????????if?(string.IsNullOrEmpty(path))
????????????{
????????????????MessageBox.Show(“path參數不能為空!“);
????????????????return;
????????????}
????????????//開啟一個下載的線程
????????????dThread?=?new?Thread(()?=>
?????????????{
?????????????????DownloadFile(url?path);
?????????????});
????????????dThread.Start();
????????}
????????void?DownloadFile(string?url?string?path)
????????{
????????????WebResponse?response?=?helper.BeginDownLoad(url);
????????????if?(response?!=?null)
????????????{
????????????????Stream?downloadSteam?=?response.GetResponseStream();
????????????????FileStream?fs?=?new?FileStream(path?FileMode.OpenOrCreate);
????????????????int?current?=?0;//當前下載字節(最多2
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????544??2018-01-26?19:09??DataCatch\App.config
?????文件????1224192??2018-01-03?14:53??DataCatch\bin\Debug\AngleSharp.dll
?????文件????1616757??2018-01-03?14:53??DataCatch\bin\Debug\AngleSharp.xm
?????文件??????24064??2018-01-30?17:22??DataCatch\bin\Debug\DataCatch.exe
?????文件????????544??2018-01-26?19:09??DataCatch\bin\Debug\DataCatch.exe.config
?????文件??????36352??2018-01-30?17:22??DataCatch\bin\Debug\DataCatch.pdb
?????文件????1506120??2015-07-23?22:18??DataCatch\bin\Debug\FSharp.Core.dll
?????文件?????697428??2015-07-23?22:18??DataCatch\bin\Debug\FSharp.Core.xm
?????文件???????4211??2018-01-26?19:54??DataCatch\DataCatch.csproj
?????文件????????228??2018-01-25?15:04??DataCatch\DataCatch.csproj.user
?????文件???????7948??2018-01-30?17:22??DataCatch\Form1.cs
?????文件??????23174??2018-01-30?16:42??DataCatch\Form1.Designer.cs
?????文件???????5817??2018-01-30?16:42??DataCatch\Form1.resx
?????文件???????9536??2018-01-30?17:55??DataCatch\HttpHelper.cs
?????文件??????????0??2018-01-30?17:22??DataCatch\obj\Debug\DataCatch.csproj.CopyComplete
?????文件?????????42??2018-01-26?19:22??DataCatch\obj\Debug\DataCatch.csproj.CoreCompileInputs.cache
?????文件????????952??2018-01-30?15:56??DataCatch\obj\Debug\DataCatch.csproj.FileListAbsolute.txt
?????文件???????1012??2018-01-30?16:42??DataCatch\obj\Debug\DataCatch.csproj.GenerateResource.Cache
?????文件??????18702??2018-01-26?19:54??DataCatch\obj\Debug\DataCatch.csprojResolveAssemblyReference.cache
?????文件??????24064??2018-01-30?17:22??DataCatch\obj\Debug\DataCatch.exe
?????文件????????180??2018-01-30?16:42??DataCatch\obj\Debug\DataCatch.FrmMain.resources
?????文件??????36352??2018-01-30?17:22??DataCatch\obj\Debug\DataCatch.pdb
?????文件????????180??2018-01-26?19:54??DataCatch\obj\Debug\DataCatch.Properties.Resources.resources
?????文件???????1464??2018-01-25?20:19??DataCatch\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????7568??2018-01-26?19:22??DataCatch\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件??????????0??2018-01-25?14:14??DataCatch\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件??????????0??2018-01-25?14:14??DataCatch\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
?????文件??????????0??2018-01-25?14:14??DataCatch\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
?????文件????????366??2018-01-26?19:22??DataCatch\packages.config
?????文件????????523??2018-01-25?14:32??DataCatch\Program.cs
............此處省略16個文件信息
- 上一篇:asp .net 本地調試工具測試搭建小工具
- 下一篇:C#貪食蛇全能版
評論
共有 條評論