Open
Conversation
Contributor
Author
|
Hello! @ilike2burnthing you've asked me to provide some test code here for this and #27. I did come back with a reply, albeit late, and I'm assuming you didn't get notified about it since the PR was merged. I'm reposting here: Make sure you're using .NET8 when compiling! using FlareSolverrSharp.Solvers;
using FlareSolverrSharp.Types;
using System.Reflection;
namespace Playground
{
class Program
{
static async Task Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine($"Usage: dotnet run {Assembly.GetExecutingAssembly().Location} <FlareSolverr URL>");
return;
}
FlareSolverr solver = new(args[0]);
FlareSolverrIndexResponse indexResponse = await solver.GetIndex();
Console.WriteLine("GetIndex() returned the following:");
Console.WriteLine($" Message = '{indexResponse.Message}'");
Console.WriteLine($" Version = '{indexResponse.Version}'");
Console.WriteLine($" UserAgent = '{indexResponse.UserAgent}'");
Console.WriteLine("Now, I'll save the UserAgent and use it WITHOUT having to call Solve() and do an expensive request.\n");
// Code that uses indexResponse.UserAgent goes here
Uri uri = new("https://setcookie.net/");
HttpRequestMessage request = new(HttpMethod.Get, uri);
Console.WriteLine($"Calling Solve() on {uri} with no cookies...");
FlareSolverrResponse response = await solver.Solve(request);
if (response.Solution.Response.Contains("Received no cookies."))
{
Console.WriteLine("Received no cookies, as expected.");
}
else
{
Console.WriteLine("Received cookies, which is unexpected!");
}
Console.WriteLine($"Calling Solve() on {uri} with 2 cookies...");
response = await solver.Solve(request, cookies: [
new Cookie() { Name = "test", Value = "value" },
new Cookie() { Name = "test2", Value = "value2" }
]);
if (response.Solution.Response.Contains("Received no cookies."))
{
Console.WriteLine("Received no cookies, which is unexpected!");
}
else if (response.Solution.Response.Contains("test = value") &&
response.Solution.Response.Contains("test2 = value2"))
{
Console.WriteLine("Received cookies, as expected.");
}
else
{
Console.WriteLine($"Something went wrong, here's the response:\n{response.Solution.Response}");
}
}
}
} |
Contributor
|
Apologies, I did see it, and I thought I'd replied with at least a 'thanks', but seemingly not. My focus at the time (I need to go back to it actually) was with FlareSolverr/FlareSolverr#1163. I'll deal with this ASAP. |
Decimation
added a commit
to Decimation/FlareSolverrSharp
that referenced
this pull request
Oct 23, 2024
Decimation
added a commit
to Decimation/FlareSolverrSharp
that referenced
this pull request
Oct 23, 2024
Decimation
added a commit
to Decimation/FlareSolverrSharp
that referenced
this pull request
Nov 20, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for FlareSolverr v3.2.0's cookies.