资源简介
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#贪食蛇全能版
相关资源
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
评论
共有 条评论