fiddler插件开发-DouYinCapture(五)

本文介绍了一款基于Fiddler的抖音爬虫插件——DouYinCapture,该插件可帮助用户抓取抖音App的数据请求。通过设置手机代理指向Fiddler,即可捕获并分析目标App的所有网络请求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

fiddler插件开发-DouYinCapture

文集 移动端爬虫
源码

  • 前言

    前面几篇文章介绍了app的自动化,但是光这样只是去掉人工操作,app运行时的请求并没有抓下来。下面介绍如何通过代理实现数据的抓取 — DouYinCapture。

  • 介绍

    DouYinCapture是fiddler的最基础最简单的一个插件即实现了IFiddlerExtension, IAutoTamper, IAutoTamper2接口的dll类库,只需要将这个dll文件加入到fiddler/scripts/下即能加载插件并按照我们的意愿过滤请求

  • 部分代码

    <pre class="md-fences md-end-block" lang="" contenteditable="false" cid="n58" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(221, 221, 221); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit inherit; background-repeat: inherit inherit;">
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Threading.Tasks;
    using Fiddler;
    using RabbitMQ.Client;

    namespace DouYinCaptuer
    {
    public class Douyin : IFiddlerExtension, IAutoTamper, IAutoTamper2
    {
    private static IModel channel;
    private void sendTask(byte[] bs, string key)
    {
    channel.BasicPublish(exchange: "DouYin",
    routingKey: key,
    basicProperties: null,
    body: bs);
    FiddlerApplication.Log.LogString("rabbitmq: send successfully");

    }
    //private static FileStream fs = new FileStream("I:\fiddlerlog\response\douyin.txt", FileMode.Append, FileAccess.Write);

    public void AutoTamperResponseAfter(Session oSession)
    {
    if (oSession.responseCode == 200)
    {
    sendTask(Encoding.UTF8.GetBytes(response), key);
    }
    }

    public void OnBeforeUnload()
    {
    FiddlerApplication.Log.LogString("卸载抖音插件成功");
    // fs.Close();
    channel.Close();
    channel.Dispose();
    }

    public void OnLoad()
    {
    FiddlerApplication.Log.LogString("加载抖音插件成功");
    ConnectionFactory rbmqfactory = new ConnectionFactory()
    {
    HostName = "",
    Port = 5672,
    UserName = "",
    Password = ""
    };
    IConnection con = rbmqfactory.CreateConnection();
    channel = con.CreateModel();
    FiddlerApplication.Log.LogString("连接RabbitMQ成功");
    }
    }
    }</pre>

    代码很简单,唯一需要注意的用了AssemblyInfo.cs的配置必须指定fiddler的最低版本,如果不指定,到时候fiddler既不报错也不能生效插件就很骚了。下面是我的fiddler的版本

    [assembly: Fiddler.RequiredVersion("5.0.20182.28034")]

9549518-20e06bd9bc7ebe3a.png
FIDDLER4.png
  • 至于如何将手机代理设置到fiddler,相关教程网上一大堆
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值