Error in webscraping problem

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Nov 17 23:40:48 EST 2016


stanleydasilva93 at gmail.com wrote:
> I am trying to solve the following problem.  Two numbers appear on a website.
> The user has to enter the gcd (greatest common divisor) and hit the submit
> button.  The catch is that the time limit is far too slow for any human
> processes -- it must be fully automated.

That's an extremely weird set of requirements. What is it,
some kind of anti-captcha, proving that you're *not* a
human?

> print firstNumber # Looks sensible -- first number probably correct
> print secondNumber # Looks sensible -- also checked
> print solution # Is indeed the correct gcd
> res = br.submit()
> 
> content = res.read()
> with open("FinalResults.html", "w") as f:
>     f.write(content)
> # Unfortunately, I examine this file to find "Wrong Answer"

If the numbers are correct, there must be something wrong
with the way you're submitting the form.

Maybe the site is expecting some cookies or header values
that you're not sending?

Are you able to submit a result successfully by hand
using a browser? If so, you might be able to use Firefox's
debugging facilities to capture the exact response being
sent, including headers and cookies.

-- 
Greg



More information about the Python-list mailing list