http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 3820|回复: 2

[需求] 用了你的助手给点意见

[复制链接]
发表于 2015-3-6 18:16:01 | 显示全部楼层 |阅读模式
要是能有个捕捉到浏览器发包的整个过程就好了 和我们平时用的抓包工具一样的 这样每次只要改几个参数就可以实现代码操作了


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2015-3-6 18:53:32 | 显示全部楼层
这个慢慢来吧,这样需要加载一个开源的引擎
 楼主| 发表于 2019-5-24 19:57:39 | 显示全部楼层
最近突然找到了一个fiddler的开发教程iddler版本:

Progress Telerik Fiddler Web Debugger
v5.0.20182.28034 for .NET 4.6.1
Built: 2018年6月27日


  
1:首先,我们用vs2017新建一个.net 4.0的类库项目(这里是错误的,下面会说,需要建4.6.1的项目,否则编译生成会失败),如下图:

  

由于我的fiddler版本比较高,对.net版本的要求会高一些,在.net 4.0版本编译生成会报错如下:

1>------ 已启动全部重新生成: 项目: fiddler-plugin-demo, 配置: Debug Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3274: 未能解析主引用“Fiddler”,因为它是针对“.NETFramework,Version=v4.6.1”框架生成的。该框架版本高于当前目标框架“.NETFramework,Version=v4.0”。
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3268: 未能解析主引用“Fiddler”,因为它对框架程序集“System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”有间接依赖关系,而在当前目标框架中未能解析该程序集。“.NETFramework,Version=v4.0”。若要解决此问题,请移除引用“Fiddler”,或将应用程序的目标重新指向包含“System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”的框架版本。
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3275: 未能解析主引用“Fiddler”,因为它对程序集“Analytics, Version=1.0.20182.27266, Culture=neutral, PublicKeyToken=2b2cea67609c9510”具有间接依赖关系,而该程序集是针对“.NETFramework,Version=v4.5”框架生成的。该框架版本高于当前目标框架“.NETFramework,Version=v4.0”。
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3275: 未能解析主引用“Fiddler”,因为它对程序集“Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”具有间接依赖关系,而该程序集是针对“.NETFramework,Version=v4.5”框架生成的。该框架版本高于当前目标框架“.NETFramework,Version=v4.0”。
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3275: 未能解析主引用“Fiddler”,因为它对程序集“GA.Analytics.Monitor, Version=1.0.20182.27266, Culture=neutral, PublicKeyToken=2b2cea67609c9510”具有间接依赖关系,而该程序集是针对“.NETFramework,Version=v4.5”框架生成的。该框架版本高于当前目标框架“.NETFramework,Version=v4.0”。
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\Properties\AssemblyInfo.cs(37,12,37,19): error CS0246: 未能找到类型或命名空间名“Fiddler”(是否缺少 using 指令或程序集引用?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(1,7,1,14): error CS0246: 未能找到类型或命名空间名“Fiddler”(是否缺少 using 指令或程序集引用?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(10,34,10,45): error CS0246: 未能找到类型或命名空间名“IAutoTamper”(是否缺少 using 指令或程序集引用?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(19,44,19,51): error CS0246: 未能找到类型或命名空间名“Session”(是否缺少 using 指令或程序集引用?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(24,45,24,52): error CS0246: 未能找到类型或命名空间名“Session”(是否缺少 using 指令或程序集引用?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(29,45,29,52): error CS0246: 未能找到类型或命名空间名“Session”(是否缺少 using 指令或程序集引用?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(34,46,34,53): error CS0246: 未能找到类型或命名空间名“Session”(是否缺少 using 指令或程序集引用?)
1>C:\Users\itsvse_pc\Documents\Visual Studio 2017\Projects\fiddler-plugin-demo\fiddler-plugin-demo\DemoExtention.cs(39,44,39,51): error CS0246: 未能找到类型或命名空间名“Session”(是否缺少 using 指令或程序集引用?)
========== 全部重新生成: 成功 0 个,失败 1 个,跳过 0 个 ==========

  

解决办法就是改成.net 4.6.1的版本即可!

2:在解决方案资源管理器中添加fiddler.exe的引用,我的fiddler安装目录为:C:\Users\itsvse_pc\AppData\Local\Programs\Fiddler,如下图:

  

3:设置插件所运行的fiddler最低版本

在项目的AssemblyInfo.cs(也可以在你代码的其他任何地方)文件中添加Fiddler.RequiredVersion 特性(Attribute)

  

4:新建一个fiddler 选项卡ui控件

需要添加 System.Windows.Forms 程序集的引用

首先在项目中添加一个用户控件取名为TestControl.cs(随意),如下图所示:

  

然后在用户控件上随意放置一个Button控件,并写一行简单的单击事件代码:

  

private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("我被点击了!!!!");
        }
复制代码
5:新建一个DemoExtention扩展类

DemoExtention类继承IAutoTamper接口,IAutoTamper 接口继承了IFiddlerExtension接口,所有实现了IAutoTamper 接口的插件将会在每一个http/https 请求或响应时被调用,所以可以用来劫持或修改http/https 请求响应数据。

注意:这个接口的方法是在后台被调用,非UI线程,如果想要更新UI,可以使用Invoke 或者 BeginInvoke 方法来更新UI。IAutoTamper 的所有方法可能会在OnLoad事件之前就执行。

代码如下:

using Fiddler;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace fiddler_plugin_demo
{
    public class DemoExtention : IAutoTamper
    {
        private TabPage tabPage; //创建插件的选项卡页
        private TestControl testControl; //MyControl自定义控件
        public DemoExtention()
        {
            this.tabPage = new TabPage("Demo测试");//选项卡的名字为Test
            this.testControl = new TestControl();
        }
        public void AutoTamperRequestAfter(Session oSession)
        {
            //throw new NotImplementedException();
        }

        public void AutoTamperRequestBefore(Session oSession)
        {
            //throw new NotImplementedException();
        }

        public void AutoTamperResponseAfter(Session oSession)
        {
            //throw new NotImplementedException();
        }

        public void AutoTamperResponseBefore(Session oSession)
        {
            //throw new NotImplementedException();
        }

        public void OnBeforeReturningError(Session oSession)
        {
            //throw new NotImplementedException();
        }

        public void OnBeforeUnload()
        {
            //throw new NotImplementedException();
        }

        public void OnLoad()
        {
            //将用户控件添加到选项卡中
            this.tabPage.Controls.Add(this.testControl);
            //为选项卡添加icon图标,这里使用Fiddler 自带的
            this.tabPage.ImageIndex = (int)Fiddler.SessionIcons.Timeline;
            //将tabTage选项卡添加到Fidder UI的Tab 页集合中
            FiddlerApplication.UI.tabsViews.TabPages.Add(this.tabPage);
            //throw new NotImplementedException();
        }
    }
}
复制代码


6:Fiddler加载插件

我们编程生成以后,把Debug目录下面的fiddler-plugin-demo.dll和fiddler-plugin-demo.pdb两个文件,复制到我们fiddler安装目录的scrip{过滤}ts文件夹,

我自己的就是:C:\Users\itsvse_pc\AppData\Local\Programs\Fiddler\scrip{过滤}ts 文件夹

  

最后,我们重启打开fiddler,可以在选项卡上面看到我们的控件了,如下图:

  

7:使插件自动部署到fiddler插件目录下

我们每次修改插件,需要重新把dll复制到scrip{过滤}ts文件夹太麻烦了,我们可以通过vs的生成事件来解决这个问题,我们重新编译生成,vs会自动把我们的dll复制到scrip{过滤}ts目录下面,在后期生成事件命令行中填写如下命令:

copy "$(TargetPath)" "C:\Users\itsvse_pc\AppData\Local\Programs\Fiddler\scrip{过滤}ts\$(TargetFilename)"
复制代码



如下图:

  

经测试,可以正常使用。
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-3-29 02:54

© 2014-2021

快速回复 返回顶部 返回列表