DO NOT DEAL WITH THIS MEMBER
Jul 24, 2019 07:46 AM
(This post was last modified: Jul 24, 2019 07:46 AM by int.)
Hello, this is a simple class I use in some of my projects.
usage:
Probably can be improved, but works fine for me (so far).
You must wait 120 seconds for it to be solved? Can't you just wait for the blocking io operation (request sent to the server) to be done and get the response?
DO NOT DEAL WITH THIS MEMBER
(Jul 24, 2019 08:28 AM)riu41776 Wrote: You must wait 120 seconds for it to be solved? Can't you just wait for the blocking io operation (request sent to the server) to be done and get the response?
If you mean wait for the downloadstring to finish, that won't work because technically 2captcha is async compared to us (when our request finishes, they haven't solved it).
Jul 24, 2019 08:29 AM
(This post was last modified: Jul 24, 2019 08:30 AM by riu41776.)
Haven't you heard of regular expressions and string interpolation feature in C# 6.0?
(Jul 24, 2019 08:29 AM)int Wrote: If you mean wait for the downloadstring to finish, that won't work because technically 2captcha is async compared to us (when our request finishes, they haven't solved it).
Yeah, after looking at the usage second time i understood that the first request is to upload the captcha and then process it. But damn, this is inefficient waiting two minutes lol. This is no use.
DO NOT DEAL WITH THIS MEMBER
(Jul 24, 2019 08:29 AM)riu41776 Wrote: Haven't you heard of regular expressions and string interpolation feature in C# 6.0?
Yeah, after looking at the usage second time i understood that the first request is to upload the captcha and then process it. But damn, this is inefficient waiting two minutes lol. This is no use.
what the fuck does regex or string interpolation have to do with this?
and if its inefficient waiting 2 minutes, then write a better way (I'm doing 2 minutes so I don't spam their servers and waste my money)
(Jul 24, 2019 08:32 AM)int Wrote: what the fugg does regex or string interpolation have to do with this?
and if its inefficient waiting 2 minutes, then write a better way (I'm doing 2 minutes so I don't spam their servers and waste my money)
You're doing string concatenation which is slow and ugly to the eyes.
String interpolation is easy as $"{Variable}SomeString".
Regex is to extract information easily... from the input text.
(Jul 24, 2019 08:37 AM)riu41776 Wrote: You're doing string concatenation which is slow and ugly to the eyes.
String interpolation is easy as $"{Variable}SomeString".
Regex is to extract information easily... from the input text.
agreed with the string interpolation, disagree with the regex
regex is slow.
stuff to improve:
-go the OOP way with this to make it "more flexible"
-start using string interpolation, much easier to read
-its 2k19, go asynchronous
-after checking the status code, get the response by split
-never ever make that delay hard-coded but rather use a slow poll loop (with a timeout ofc)
-for god's sake, dont expect everything to be perfect and at least check the status codes
-remove the console.write part
-use tasks (for cancellation + tons of other shit)
I'll leave the learning part to you. if you're confused with any part lmk
“I wish I could say everything in one word. I hate all the things that can happen between the beginning of a sentence and the end.” ~ Leonard Cohen
DO NOT DEAL WITH THIS MEMBER
Jul 24, 2019 08:42 AM
(This post was last modified: Jul 24, 2019 08:44 AM by int.)
(Jul 24, 2019 08:37 AM)riu41776 Wrote: You're doing string concatenation which is slow and ugly to the eyes.
String interpolation is easy as $"{Variable}SomeString".
Regex is to extract information easily... from the input text.
I would have just called it string.format instead of string interpolation, which I guess is better, but I'm used to string concat
(Jul 24, 2019 08:42 AM)vaiperboy Wrote: stuff to improve:
-go the OOP way with this to make it "more flexible"
-start using string interpolation, much easier to read
-its 2k19, go asynchronous
-after checking the status code, get the response by split
-never ever make that delay hard-coded but rather use a slow poll loop (with a timeout ofc)
-for god's sake, dont expect everything to be perfect and at least check the status codes
-remove the console.write part
-use tasks (for cancellation + tons of other shit)
I'll leave the learning part to you. if you're confused with any part lmk
- ok
- maybe
- probably not
- should probably check status code
- delay is a slow poll loop RN, in my other projects
- yeah, in C++ I would have done more error handling and shit
- used for debugging
- fuck tasks
(Jul 24, 2019 08:39 AM)tweety Wrote: agreed with the string interpolation, disagree with the regex
regex is slow.
Regex is "slow" on huge inputs, but i still don't agree with it being slow.
We're in 2019, hardware are getting better so your opinion would be true years ago.
DO NOT DEAL WITH THIS MEMBER
(Jul 24, 2019 08:44 AM)riu41776 Wrote: Regex is "slow" on huge inputs, but i still don't agree with it being slow.
We're in 2019, hardware are getting better so your opinion would be true years ago.
regex is for fucking idiots fuck regex
Most of the "coders" i see here are amateurs not applying OOP techniques like SOLID principles and programming against interfaces instead of implementations.
(Jul 24, 2019 08:42 AM)int Wrote: I would have just called it string.format instead of string interpolation, which I guess is better, but I'm used to string concat
- ok
- maybe
- probably not
- should probably check status code
- delay is a slow poll loop RN, in my other projects
- yeah, in C++ I would have done more error handling and shit
- used for debugging
- fugg tasks and why is that? tasks are perfect for your job
you can cancel one whenever you like
“I wish I could say everything in one word. I hate all the things that can happen between the beginning of a sentence and the end.” ~ Leonard Cohen
DO NOT DEAL WITH THIS MEMBER
(Jul 24, 2019 08:47 AM)vaiperboy Wrote: and why is that? tasks are perfect for your job
you can cancel one whenever you like
tasks are retarded as fuck, last I tried it was either in java for some android garbage or discord bots
didn't like the format
Jul 24, 2019 08:54 AM
(This post was last modified: Jul 24, 2019 08:55 AM by vaiperboy.)
(Jul 24, 2019 08:51 AM)int Wrote: tasks are retarded as fugg, last I tried it was either in java for some android garbage or discord bots
didn't like the format mate, whats the issue?
Code public static Task<string> send_captcha(CancellationToken cancel) {
await the stuff;
return big ?? string.Empty; // never return null
}
Code await send_captcha(CancellationToken.None); // <<< This will return string
“I wish I could say everything in one word. I hate all the things that can happen between the beginning of a sentence and the end.” ~ Leonard Cohen
|