using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
class Program
{
static void Main(string[] args)
{
var options = new ChromeOptions();
options.AddArgument("--start-maximized");
IWebDriver driver = new ChromeDriver(options);
var xhrUrls = new List<string>();
var handler = new NetworkRequestHandler();
handler.RequestTransformer = (request) => { return request; };
handler.RequestMatcher = httprequest =>
{
if (httprequest.Method == "GET" && (httprequest.Url.Contains(".fpm4") || httprequest.Url.Contains(".m4a")))
{
xhrUrls.Add(httprequest.Url);
}
return true;
};
INetwork networkInterceptor = driver.Manage().Network;
networkInterceptor.AddRequestHandler(handler);
networkInterceptor.StartMonitoring();
driver.Navigate().GoToUrl("https://store.epicgames.com/en-US/p/tunche");
driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(30);
networkInterceptor.StopMonitoring();
foreach (var url in xhrUrls)
{
Console.WriteLine(url);
}
driver.Quit();
}
}
- вот такой код запускается, но выдает исключение: Unhandled exception. OpenQA.Selenium.DevTools.CommandResponseException: Fetch.continueRequest: Invalid parameters - Failed to deserialize params.postData - BINDINGS: invalid base64 string at position 152<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FFMpegCore" Version="5.1.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.8.2" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="111.0.5563.6400" />
</ItemGroup>
</Project>
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
class Program
{
static void Main(string[] args)
{
var options = new ChromeOptions();
options.AddArgument("--start-maximized");
IWebDriver driver = new ChromeDriver(options);
var xhrUrls = new List<string>();
var handler = new NetworkRequestHandler();
handler.RequestMatcher = httprequest =>
{
if (httprequest.Url.Contains(".fpm4") || httprequest.Url.Contains(".m4a"))
{
xhrUrls.Add(httprequest.Url);
}
return true;
};
INetwork networkInterceptor = driver.Manage().Network;
networkInterceptor.AddRequestHandler(handler);
networkInterceptor.StartMonitoring();
driver.Navigate().GoToUrl("https://store.epicgames.com/en-US/p/tunche");
driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(30);
networkInterceptor.StopMonitoring();
foreach (var url in xhrUrls)
{
Console.WriteLine(url);
}
driver.Quit();
}
}
- Вот в чем может быть проблема? Может просто сам сайт типо блочит?Включает защиту?Не может такого быть?