抓取拼多多工作台信息
This commit is contained in:
1 parent
1745f3c397
commit
e25cc1b51e
22 files changed
+1130
-57
No files matched your search
@@ -23,7 +23,7 @@ namespace TemuKJD.Helper
|
||||
public class BaseResourceRequestHandler : ResourceRequestHandler
|
||||
{
|
||||
public string UserAgent = string.Empty;
|
||||
public Func<object, string, string, bool> BeforeResourceLoadEvent; // sender, requestUrl, postData, true(表示取消执行)
|
||||
public Func<object, string, string, IRequest, bool> BeforeResourceLoadEvent; // sender, requestUrl, postData, true(表示取消执行)
|
||||
public Action<object, string, string, string, IRequest> ResourceLoadCompleteEvent; // sender, requestUrl, postData, responseData
|
||||
public Action<object, string, string, string> ResourceRedirectEvent; // sender, requestUrl, postData, redirectUrl
|
||||
public string[] ResourceContentTypeRegister = new string[] { "application/json", "javascript", "application/x-www-form-urlencoded", "text/html", "text/plain" };
|
||||
@@ -96,7 +96,7 @@ namespace TemuKJD.Helper
|
||||
try
|
||||
{
|
||||
string postData = GetPostData(request);
|
||||
bool? result = BeforeResourceLoadEvent?.Invoke(chromiumWebBrowser, request.Url, postData);
|
||||
bool? result = BeforeResourceLoadEvent?.Invoke(chromiumWebBrowser, request.Url, postData, request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
using AllBase.Model.Result;
|
||||
using Fiddler;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TemuKJD.BaseForms;
|
||||
|
||||
namespace TemuKJD.Helper
|
||||
{
|
||||
public class FddlHelper
|
||||
{
|
||||
|
||||
public bool InstallCertificate()
|
||||
{
|
||||
//FiddlerApplication.Log.LogString($"安装证书,为了监听https请求");
|
||||
if (!CertMaker.rootCertExists())
|
||||
{
|
||||
if (!CertMaker.createRootCert() || !CertMaker.trustRootCert())
|
||||
{
|
||||
BaseMsgForm.ShowError("证书安装失败,请重试!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>启动fiddlercore本地设置的代理端口监听</summary>
|
||||
public void StartupFiddlerCore(int port = 9898)
|
||||
{
|
||||
//Console.WriteLine("fiddler启动了...listening: port: 127.0.0.1:" + port);
|
||||
FiddlerApplication.Startup(port, FiddlerCoreStartupFlags.Default | FiddlerCoreStartupFlags.RegisterAsSystemProxy);
|
||||
//FiddlerApplication.Log.LogString($"Created endpoint listening on port {CONFIG.ListenPort}");
|
||||
}
|
||||
|
||||
public void AttachListening()
|
||||
{
|
||||
//FiddlerApplication.OnNotification += (o, nea) => Console.WriteLine($"** NotifyUser: {nea.NotifyString}");
|
||||
//FiddlerApplication.Log.OnLogString += (o, lea) => Console.WriteLine($"** LogString: {lea.LogString}");
|
||||
|
||||
FiddlerApplication.BeforeRequest += FiddlerApplication_BeforeRequest;
|
||||
FiddlerApplication.BeforeResponse += FiddlerApplication_BeforeResponse;
|
||||
}
|
||||
|
||||
/// <summary>拦截请求返回Request信息</summary>
|
||||
private void FiddlerApplication_BeforeRequest(Session oSession)
|
||||
{
|
||||
//Debug.WriteLine(oSession.fullUrl);
|
||||
|
||||
// In order to enable response tampering, buffering mode MUST
|
||||
// be enabled; this allows FiddlerCore to permit modification of
|
||||
// the response in the BeforeResponse handler rather than streaming
|
||||
// the response to the client as the response comes in.
|
||||
oSession.bBufferResponse = false;
|
||||
|
||||
// Set this property if you want FiddlerCore to automatically authenticate by
|
||||
// answering Digest/Negotiate/NTLM/Kerberos challenges itself
|
||||
//session["X-AutoAuth"] = "(default)";
|
||||
|
||||
//FiddlerApplication.Log.LogString($" {oSession.fullUrl }");
|
||||
}
|
||||
|
||||
/// <summary>拦截请求返回Response信息</summary>
|
||||
private void FiddlerApplication_BeforeResponse(Session oSession)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>关闭fiddlercore设置的代理</summary>
|
||||
public void UninstallFiddler()
|
||||
{
|
||||
if (FiddlerApplication.IsStarted())
|
||||
{
|
||||
FiddlerApplication.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>卸载证书</summary>
|
||||
public bool UninstallCertificate()
|
||||
{
|
||||
if (CertMaker.rootCertExists())
|
||||
{
|
||||
if (!CertMaker.removeFiddlerGeneratedCerts(true))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user