简体   繁体   English

使用RestSharp获取Solvemedia图像

[英]Get Solvemedia image using RestSharp

I'm developing an application which needs to make a query on a website to extract certain data, such as the user's name, points / remaining balance etc. 我正在开发一个需要在网站上进行查询以提取某些数据的应用程序,例如用户名,积分/剩余余额等。

I present a problem in the login, the client needs to solve a captcha solvemedia to be able to enter the website, I would like to extract the image of this captcha and show it to the client but I am having problems to extract it, i'm trying to do it through http requests with RestSharp, the reason I do not do it with a webbrowser or selenium is that it spends a lot more resources. 我在登录时遇到问题,客户端需要解决验证码SolventMedia才能进入网站,我想提取此验证码的图像并将其显示给客户端,但提取时遇到问题,我我正在尝试通过RestSharp通过http请求来执行此操作,之所以我不使用Web浏览器或Selenium来执行此操作,是因为它花费了很多资源。

i try this: 我试试这个:

RestClient restClient = new RestClient(@"//api-secure.solvemedia.com/papi/media?c=2@gAB09NHSertXLv3TnpobmKDxvkjsaT4m@X4wLMdkN.u0ENU8bgrS3KH9APTC4lJjokJaIfZePPIgNLL84QkOaQlXcxzHvOVTTU98Of7mo8BoC0QQuiH1RMqMrGof6BbL-tReeY8AHhPA7-nwvQKLqUEXQwTL4HhLXfZVre9jccpqQxFGIRYZH1ZQoAKCV5k1TGCLXXP9vMVsJFntDNz6Ozik02MANT1siBJRYTNIpGcj6p6Gbq5j0HvQChz7jtgdzwlj7nee0BdZphpg27ikQlVB5IUelMvSjzNNvPZawB9YbC9v6zyJngNQaJIJku2SPJkhFXIK0uoA;w=300;h=150;fg=000000;bg=f8f8f8");
var fileBytes = restClient.DownloadData(new RestRequest("#", Method.GET));
File.WriteAllBytes(Path.Combine(directory, "poster-got.jpg"), fileBytes);

The problem with this is that I only get an image that says "Media Error", Is there any way to get the image that is sent when you request the login page? 问题是我只得到一个显示“媒体错误”的图像,请问有什么方法可以获取当您请求登录页面时发送的图像吗? Can it be done with restsharp? 可以用restsharp完成吗? , if not with what library could I do it? ,如果没有,我可以使用哪个库呢?

For downloading image I use https://github.com/jgiacomini/Tiny.RestClient 要下载图像,请使用https://github.com/jgiacomini/Tiny.RestClient

But when I try to view your image in in my browser I have a media error. 但是,当我尝试在浏览器中查看您的图像时,出现媒体错误。 I think you use a wrong url. 我认为您使用了错误的网址。

In your case using Tiny.RestClient; 在您的情况下使用Tiny.RestClient;

var client = new TinyRestClient(new HttpClient(), "@"http//api-secure.solvemedia.com");
FileInfo fileInfo = await client.
GetRequest("papi/media").
AddQueryParameter("2@gAB09NHSertXLv3TnpobmKDxvkjsaT4m@X4wLMdkN.u0ENU8bgrS3KH9APTC4lJjokJaIfZePPIgNLL84QkOaQlXcxzHvOVTTU98Of7mo8BoC0QQuiH1RMqMrGof6BbL-tReeY8AHhPA7-nwvQKLqUEXQwTL4HhLXfZVre9jccpqQxFGIRYZH1ZQoAKCV5k1TGCLXXP9vMVsJFntDNz6Ozik02MANT1siBJRYTNIpGcj6p6Gbq5j0HvQChz7jtgdzwlj7nee0BdZphpg27ikQlVB5IUelMvSjzNNvPZawB9YbC9v6zyJngNQaJIJku2SPJkhFXIK0uoA;w=300;h=150;fg=000000;bg=f8f8f8").
DownloadFileAsync("c:\"poster-got.jpg");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM