NATION

PASSWORD

PHP bot stopped working due to CAPTCHA restrictions

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.
User avatar
Aibohphobia
Spokesperson
 
Posts: 200
Founded: Mar 15, 2012
Ex-Nation

PHP bot stopped working due to CAPTCHA restrictions

Postby Aibohphobia » Sat Nov 03, 2018 6:35 pm

Good day.

I have a PHP bot connected to the following nation: Aleator. It randomly picks responses to issues twice a day. It has recently stopped working, because the page is blocked by a CAPTCHA. I was wondering if there was anything I could do about it. If any information is needed on the bot, please let me know.

Thank you in advance for any help you can provide.

User avatar
Darcania
Envoy
 
Posts: 205
Founded: Dec 29, 2014
Civil Rights Lovefest

Postby Darcania » Sat Nov 03, 2018 8:04 pm

The NS API provides a method to answer issues programmatically: https://www.nationstates.net/pages/api. ... tecommands

User avatar
Aibohphobia
Spokesperson
 
Posts: 200
Founded: Mar 15, 2012
Ex-Nation

Postby Aibohphobia » Sat Nov 03, 2018 9:06 pm

Darcania wrote:The NS API provides a method to answer issues programmatically: https://www.nationstates.net/pages/api. ... tecommands

I know. The bot was written before the changes were introduced to the API, and the CAPTCHA issue only occured, like, yesterday.

User avatar
Eluvatar
Director of Technology
 
Posts: 3086
Founded: Mar 31, 2006
New York Times Democracy

Postby Eluvatar » Sat Nov 03, 2018 10:42 pm

Generally speaking, once something is possible via API, we would like script authors to shift away from using HTML scraping.

This need not happen instantaneously, that'd be a bit rough, but scraping-based scripts are unsupported at the best of times.

All this being said, a cursory look has me very confused as to how your nation could get a CAPTCHA in issue selection. That should pretty much only happen for minigames, was my belief.
To Serve and Protect: UDL

Eluvatar - Taijitu member

User avatar
Aibohphobia
Spokesperson
 
Posts: 200
Founded: Mar 15, 2012
Ex-Nation

Postby Aibohphobia » Sun Nov 04, 2018 3:23 pm

Eluvatar wrote:Generally speaking, once something is possible via API, we would like script authors to shift away from using HTML scraping.

This need not happen instantaneously, that'd be a bit rough, but scraping-based scripts are unsupported at the best of times.

All this being said, a cursory look has me very confused as to how your nation could get a CAPTCHA in issue selection. That should pretty much only happen for minigames, was my belief.

I was planning on doing it through the API eventually, but I have very little spare time during my days. Now I'm kind of forced into doing it anyway, so, I guess, I should've found the time before. I will let you know how it goes.

Yes, it was my belief as well. The CAPTCHA might be enforced by the hosting company though, I'm not sure. This is what it looks like:

Image

Update #0: trying to login through the API produces the same CAPTCHA page... I have no idea how to get around it if that's the case.

Update #1: I have managed to produce a CAPTCHA response, but sending it to https://nationstates.net/cdn-cgi/l/chk_captcha (which, I am assuming, is where the validation script sits) produces a "302 Temporarily Moved". The CAPTCHA challenge seems to be tied to my server's IP address, as I am not getting it when logging into the nation normally, and it doesn't disappear if I create a new cookie for the bot. Neither POST nor GET works, and the "Location" header for the 302 page is simply root ("/"). I'm out of ideas.

Update #2: the CAPTCHA is definitely tied to my server's IP address, as I have copied the cookie from the bot into my browser's storage, and there is no CAPTCHA challenge when viewing the pages within the browser.
Last edited by Aibohphobia on Mon Nov 05, 2018 12:14 am, edited 4 times in total.

User avatar
Aibohphobia
Spokesperson
 
Posts: 200
Founded: Mar 15, 2012
Ex-Nation

Postby Aibohphobia » Sun Nov 18, 2018 8:38 pm

Should I move this question to Stackoverflow or something? Or does someone with more knowledge and/or power have recommendations on how to deal with this problem?

User avatar
Ever-Wandering Souls
Negotiator
 
Posts: 7267
Founded: Jan 01, 2014
Father Knows Best State

Postby Ever-Wandering Souls » Sun Nov 18, 2018 8:44 pm

Aibohphobia wrote:Should I move this question to Stackoverflow or something? Or does someone with more knowledge and/or power have recommendations on how to deal with this problem?


I'm no admin and only a minor tech-head, but the fact that it's a cloudflare response does sound like cloudflare, which NS uses for protection, has singled out your server. It's at least not impossible that this is the case, and it's thus an issue ...tangentially related to NS?

Image


https://support.cloudflare.com/hc/en-us ... e-visitor-

From what is said there, it does sound like it's something NS needs to deal with.
Last edited by Ever-Wandering Souls on Sun Nov 18, 2018 8:46 pm, edited 1 time in total.
Proud Raider; General of The Black Hawks, Ret.
TG me anytime; I'm always happy to talk about anything!

The Alicorns (Equestria) wrote:Let them stay, no need to badmouth them...From our view a bunch of nations just came in, seized the delegate position, and changed a few superficial things...we play NationStates differently...there's really no reason for us to be butthurt.
http://www.nationstates.net/page=rmb/postid=8944227
http://www.nationstates.net/page=rmb/postid=8951258

Misley wrote:
Hobbesistan wrote:Don't think I understand the question.
The color or what?..

Jesus, Hobbes, it's 2015. You can't just call someone "the color".

Reploid Productions wrote:Raiders are endlessly creative

How Do I Telegram API?

Omnis delenda est.

User avatar
Wolfram and Hart
Secretary
 
Posts: 37
Founded: Jul 06, 2017
Father Knows Best State

Postby Wolfram and Hart » Wed Nov 21, 2018 2:59 pm

Doesn't fix your problem, but you might be interested in this script that answers issues via API
viewtopic.php?f=12&t=423382&start=58

User avatar
Aibohphobia
Spokesperson
 
Posts: 200
Founded: Mar 15, 2012
Ex-Nation

Postby Aibohphobia » Thu Nov 22, 2018 6:17 pm

Wolfram and Hart wrote:Doesn't fix your problem, but you might be interested in this script that answers issues via API
viewtopic.php?f=12&t=423382&start=58

Thank you. It actually might. Unless the bloody http/https "mixed active content" problem arises again. My server runs on http, and NS has forced https.
If it doesn't work from my server, I can always run it locally until my server's IP is removed from Cloudflare's blacklist or someone from NS' administration helps delisting it.
I will have to modify your script, however. I find it difficult to even look at "getElementsByTagName()" and "getAttribute()", sorry :ugeek:
Last edited by Aibohphobia on Thu Nov 22, 2018 6:21 pm, edited 1 time in total.

User avatar
Aibohphobia
Spokesperson
 
Posts: 200
Founded: Mar 15, 2012
Ex-Nation

Postby Aibohphobia » Sun Dec 23, 2018 2:58 am

[violet] seems to have unbanned my server's IP address, for which I am very grateful. I am glad to finally be able to take some matters out of my head.


Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Addy and Arielle, All are Equal, Bali Kingdom, DeltaSource, Doughworld, Inferior, Ioudaia, Kirkas, Montrandec, Radicalania, Ruhmheim, Skiva, The Controlist Ferwerter Union, Unionization of European Countries

Advertisement

Remove ads