Fidder插件自动生成爬虫代码(C#)
原创,效果如下:

1、新建项目,并添加Fidder.exe的引用:

2、添加代码
[assembly: Fiddler.RequiredVersion("2.2.8.6")]
using Fiddler;
using System;
using System.Windows.Forms;
public class MyExtension : IHandleExecAction, IFiddlerExtension
{
private TabPage tabPage; //创建插件的选项卡页
private UserControl myCtrl; //UserControl
public MyExtension()
{
#region makeUC
var uc = new System.Windows.Forms.UserControl();
var txtCode = new System.Windows.Forms.RichTextBox();
txtCode.Dock = System.Windows.Forms.DockStyle.Fill;
txtCode.Location = new System.Drawing.Point(, );
txtCode.Name = "txtCode";
txtCode.Size = new System.Drawing.Size(, );
uc.Controls.Add(txtCode);
#endregion
//构造函数中实例化对象
this.myCtrl = uc;
this.myCtrl.Dock = DockStyle.Fill;
this.tabPage = new TabPage("Coder");//选项卡的名字为Test
}
public void OnLoad()
{
//将用户控件添加到选项卡中
this.tabPage.Controls.Add(this.myCtrl);
//为选项卡添加icon图标,这里使用Fiddler 自带的
this.tabPage.ImageIndex = (int)Fiddler.SessionIcons.Timeline;
//将tabTage选项卡添加到Fidder UI的Tab 页集合中
FiddlerApplication.UI.tabsViews.TabPages.Add(this.tabPage);
FiddlerApplication.UI.lvSessions.SelectedIndexChanged += LvSessions_SelectedIndexChanged;
}
public void OnBeforeUnload()
{
}
private void LvSessions_SelectedIndexChanged(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
var sessions = FiddlerApplication.UI.GetSelectedSessions();
if (sessions != null)
{
if (sessions.Length > )
{
sb.Append(" HttpHelper httpHelper = new HttpHelper();\r\n");
}
foreach (var item in sessions)
{
sb.Append(Raw2Code(item.RequestHeaders.ToString(true, true, true)));
}
}
myCtrl.Controls[].Text = sb.ToString();
}
private string Raw2Code(string rawText)
{
return "请加QQ:351392535;www.shujucaiji.cn";
}
bool IHandleExecAction.OnExecAction(string sCommand)
{
string[] strArray = Utilities.Parameterize(sCommand);
var aa = FiddlerApplication.UI.GetAllSessions();
return true;
}
//public void AutoTamperRequestBefore(Session oSession)
//{
// /*在这编写请求之前需要执行的code */
//}
//public void AutoTamperRequestAfter(Session oSession)
//{
// /*在这编写请求之后需要执行的code */
//}
//public void AutoTamperResponseBefore(Session oSession)
//{
// /*在这编写响应之前需要执行的code */
// myCtrl.txtCode.Text = Raw2Code(oSession.RequestHeaders.ToString(true, true, true));
//}
//public void AutoTamperResponseAfter(Session oSession)
//{
// /*在这编写响应之后需要执行的code */
//}
//public void OnBeforeReturningError(Session oSession)
//{
// /*在这编写有错误返回时需要执行的code */
//}
}
3、编译并将dll拷贝到Fidder的Script目录下。
或者在:后期生成事件命令行中添加:copy "$(TargetPath)" "%ProgramFiles%\Fiddler2\Scripts\$(TargetFilename)"

4、打开Fidder
Fidder插件自动生成爬虫代码(C#)的更多相关文章
- SpringBoot系列: 使用MyBatis maven插件自动生成java代码
====================================pom.xml 文件====================================需要在 pom.xml 文件增加 m ...
- 【mybatis源码学习】利用maven插件自动生成mybatis代码
[一]在要生成代码的项目模块的pom.xml文件中添加maven插件 <!--mybatis代码生成器--> <plugin> <groupId>org.mybat ...
- Eclipse 使用mybatis generator插件自动生成代码
Eclipse 使用mybatis generator插件自动生成代码 标签: mybatis 2016-12-07 15:10 5247人阅读 评论(0) 收藏 举报 .embody{ paddin ...
- 使用Mybatis Generator插件自动生成映射文件(cmd无法进入文件,dns服务器对区域没有权威等问题)遇到问题
使用Mybatis Genertor插件自动生MyBatis所需要的DAO接口,实体模型类,Mapping映射文件,将生成的代码赋值到项目工程中即可. 有命令行,Eclipse插 ...
- Intellij IDEA集成mybatis-generator插件自动生成数据库实体操作类
Intellij IDEA集成mybatis-generator插件自动生成数据库实体操作类 转载至:https://blog.csdn.net/fishinhouse/article/details ...
- 借Adobe XD之力,自动生成Flutter代码
概述 今天,我们来聊聊一个专门为"懒人程序员"准备的工具--Adobe XD.使用它可以快速将原型设计图转换为可执行的Flutter代码, 而由于Flutter自身跨平台的特性,因 ...
- [Dynamic Language] 用Sphinx自动生成python代码注释文档
用Sphinx自动生成python代码注释文档 pip install -U sphinx 安装好了之后,对Python代码的文档,一般使用sphinx-apidoc来自动生成:查看帮助mac-abe ...
- Mybatis-Generator插件自动生成Dao、Model、Mapping相关文件
最近做项目,mapping 有点多而且容易写错,于是试着用了Mybatis-Generator 插件自动生成 dao, domain mapping 文件.感觉还挺好用.把相关配置分享,一边以后做项 ...
- wsdl自动生成Java代码,根据wsdl生成Java代码
wsdl自动生成Java代码,根据wsdl生成Java代码 >>>>>>>>>>>>>>>>>&g ...
随机推荐
- 同一域名对应多个IP时,PHP获取远程网页内容的函数
同一域名对应多个IP时,PHP获取远程网页内容的函数 [文章作者:张宴 本文版本:v1.0 最后修改:2008.12.15 转载请注明原文链接:http://blog.zyan.cc/post/389 ...
- 关于不重启Tomcat自动加载改变的class文件
修改server.xml,在Host标签下加入以下配置 <Context path="" docBase="FileManager" reloadable ...
- 红黑树(RB-tree)比AVL树的优势在哪?
1. 如果插入一个node引起了树的不平衡,AVL和RB-Tree都是最多只需要2次旋转操作,即两者都是O(1):但是在删除node引起树的不平衡时,最坏情况下,AVL需要维护从被删node到root ...
- 深度学习笔记(十)Augmentation for small object detection(翻译)
一. abstract 这些年来,目标检测取得了令人瞩目的成就.尽管改进很大,但对于小目标和大目标的检测性能差异还是蛮大的.我们在 MS COCO 数据集上分析了如今一个比较先进的算法,Mask-RC ...
- input输入框如何只能输入非零开头的正整数
input输入框如何只能输入非零开头的正整数 ********* 废话不多说,先来代码 ********* case1: 原生html + javascript <body> <!- ...
- Python3学习笔记(十五):常用时间模块time和datetime
一.time模块 1.时间戳 time.time() :从1970-01-01到至今的秒数 import time print(time.time()) 1529238004.2784646 2.等待 ...
- Spring boot之JPA
JPA 步骤: (1)在pom.xml添加mysql,spring-data-jpa依赖 (2)在application.properties文件中配置mysql连接配置文件 (3)在applicat ...
- JPA 开发写SQL时候遇见的困难点
官方文档 https://docs.spring.io/spring-data/jpa/docs/1.11.16.RELEASE/reference/html/#repositories.specia ...
- vue-cli构建一个工程
使用前,必须要先按照 node:安装node Vue CLI官方文档:https://cli.vuejs.org/zh/ 安装node地址:https://nodejs.org/zh-cn/downl ...
- C++入门经典-例3.22-循环嵌套打印三角形
1:代码如下: // 3.22.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> usin ...