Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to handle captcha through machanize module or any module

607 views
Skip to first unread message

Jai

unread,
Dec 18, 2013, 7:56:17 AM12/18/13
to
please do replay how to handle captcha through machanize module

Jai

unread,
Dec 18, 2013, 8:24:04 AM12/18/13
to
#/usr/bin/env python

import mechanize, re
import cookielib
import cgi
import urllib2
from random import choice

def get_domain(url):
return urlparse.urlparse(url).netloc


if __name__=="__main__":
br = mechanize.Browser()
cj = cookielib.LWPCookieJar()
br.set_proxies({"http": "217.174.155.73:8080"})
br.set_cookiejar(cj)
br.addheaders = [('User-agent', 'Firefox')]
br.set_handle_equiv(True)
br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
br.set_handle_refresh(False) # can sometimes hang without this
url = "http://goarticles.com/"
response = br.open(url)
print response.info()
link_list = []
for link in br.links():
match = re.search(r"register", str(link.url))
if match:
link2 = (link.base_url[:-1]+link.url)
if link2 not in link_list:
link_list.append(link2)
print link2

response2 = br.open(link2)
for form in br.forms():
form.set_all_readonly(False)

br.form = list(br.forms())[1] # use when form is unnamed
for control in br.form.controls:
if str(control.type) == "text" and str(control.name) =="email":
br.form[str(control.name)]="jaipr...@wisepromo.com"
elif str(control.type)=="text":
br.form[str(control.name)]="mybot"+control.name
elif str(control.type) =="select":
br.form[str(control.name)]=[str(control.items[1])]
elif str(control.type) =="password":
br.form[str(control.name)] = "mybotpassword213"
elif str(control.type)=="checkbox":
br.find_control(str(control.name)).items[0].selected=True
elif re.search(r"captcha",str(control.name)):
br.form[str(control.name)] = "mybotcaptcha"
else:
pass
#elif str(control.type)=="submit":

responce = br.submit()
print responce.info()
#print responce.read()





sir , i am very new to python i have just started to learn it ,

my aim is to practice
1)simple automatic form registration,
2)simple automatic vitrification
3)simple automatic loging

this site http://goarticles.com/register.html

sir i m referring the mechanize module

now i am stuck on two thing

1) how to automatically handling the captcha on this form
2) how to verify or the filled form

please help i have already gave 2 days on this just i want some clue from ur side

Robert Kern

unread,
Dec 18, 2013, 8:29:30 AM12/18/13
to pytho...@python.org
On 2013-12-18 12:56, Jai wrote:
> please do replay how to handle captcha through machanize module

You've asked the same question twice now. You have received the only answer that
you are going to get here: we won't help you do this. We may help you learn to
do other stuff with Python, but not this. Please stop asking this question.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Joel Goldstick

unread,
Dec 18, 2013, 9:48:46 AM12/18/13
to Robert Kern, pytho...@python.org
On Wed, Dec 18, 2013 at 8:29 AM, Robert Kern <rober...@gmail.com> wrote:
On 2013-12-18 12:56, Jai wrote:
please do replay how to handle captcha through machanize module

You've asked the same question twice now. You have received the only answer that you are going to get here: we won't help you do this. We may help you learn to do other stuff with Python, but not this. Please stop asking this question.
 
Jai,

The first time you asked for help you used all capital letters. People usually don't take that well, since it is like yelling.  As Robert pointed out, you then asked the same question again.  This is also not good.  Then you complain that you haven't been given service in two days.

So, what you need to do is show a small coding example of the problem you are having.  Give the OS, the python version, and copy the traceback if there is an error.


--

Chris Angelico

unread,
Dec 18, 2013, 9:51:28 AM12/18/13
to pytho...@python.org
On Thu, Dec 19, 2013 at 1:48 AM, Joel Goldstick
<joel.go...@gmail.com> wrote:
> So, what you need to do is show a small coding example of the problem you
> are having. Give the OS, the python version, and copy the traceback if
> there is an error.

And give a good solid reason why you need to automate a CAPTCHA,
because none of us here wants to contribute to the eternal problem of
spam.

ChrisA

Michael Torrie

unread,
Dec 18, 2013, 1:11:21 PM12/18/13
to pytho...@python.org
Nor do we wish to be party to helping you violate goarticle's terms of
service. If you do violate their terms of service, then you forfeit any
right to view their content.

Mark Lawrence

unread,
Dec 18, 2013, 1:21:50 PM12/18/13
to pytho...@python.org
Sadly by answering their previous questions going back to 19/11/2013
perhaps we've already, inadvertently set them off down this sticky path.
Oh, I just wish I'd attended that management course about advance
hindsight :(

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Joel Goldstick

unread,
Dec 18, 2013, 1:31:47 PM12/18/13
to Mark Lawrence, pytho...@python.org
On Wed, Dec 18, 2013 at 1:21 PM, Mark Lawrence <bream...@yahoo.co.uk> wrote:
On 18/12/2013 18:11, Michael Torrie wrote:
On 12/18/2013 07:51 AM, Chris Angelico wrote:
On Thu, Dec 19, 2013 at 1:48 AM, Joel Goldstick
<joel.go...@gmail.com> wrote:
So, what you need to do is show a small coding example of the problem you
are having.  Give the OS, the python version, and copy the traceback if
there is an error.

And give a good solid reason why you need to automate a CAPTCHA,
because none of us here wants to contribute to the eternal problem of
spam.

Nor do we wish to be party to helping you violate goarticle's terms of
service.  If you do violate their terms of service, then you forfeit any
right to view their content.


Sadly by answering their previous questions going back to 19/11/2013 perhaps we've already, inadvertently set them off down this sticky path.  Oh, I just wish I'd attended that management course about advance hindsight :(

The OP seems to be a kind of 'drive by' questioner.  He yells out his plea as his ride cruises by.  Around the block and yell again.

Denis McMahon

unread,
Dec 18, 2013, 2:58:53 PM12/18/13
to
On Wed, 18 Dec 2013 04:56:17 -0800, Jai wrote:

> please do replay how to handle captcha through machanize module

The purpose of a captcha is to prevent automated scraping of data. Many
of us may choose, or even need, to use captcha. What on earth makes you
think for one minute that we'll help you bypass them.

--
Denis McMahon, denismf...@gmail.com

SACHIN CHAVAN

unread,
May 23, 2018, 1:23:08 AM5/23/18
to
On Wednesday, December 18, 2013 at 6:26:17 PM UTC+5:30, Jai wrote:
> please do replay how to handle captcha through machanize module

I have the same issue, nothing find a solution yet!

MRAB

unread,
May 23, 2018, 2:01:42 PM5/23/18
to
The purpose of captcha is to ensure that talking to a human, not a bot.
It does that by presenting a task that's impossible, or at least
extremely difficult, to do, so it's not surprising that you haven't
found a solution.

Chris Angelico

unread,
May 23, 2018, 2:12:45 PM5/23/18
to
On Thu, May 24, 2018 at 4:01 AM, MRAB <pyt...@mrabarnett.plus.com> wrote:
> On 2018-05-23 06:22, SACHIN CHAVAN wrote:
>>
> The purpose of captcha is to ensure that talking to a human, not a bot. It
> does that by presenting a task that's impossible, or at least extremely
> difficult, to do, so it's not surprising that you haven't found a solution.

Obligatory XKCD: https://xkcd.com/810/ (caution, language - contains a
precision F-strike)

ChrisA

Ben Finney

unread,
May 23, 2018, 7:59:38 PM5/23/18
to
Jai <jaiprakas...@gmail.com> writes:

> please do replay how to handle captcha through machanize module

Step 1: ‘import mechanize’.

Step 2: be an actual human, and interact manually with the CAPTCHA.

If you are attempting to fool a CAPTCHA with an automated tool, you are
entering an arms race against those who design the CAPTCHA to *prevent*
exactly what you're doing.

Any technique someone can describe to fool the CAPTCHA, will most likely
already be considered as part of the design of the more effective
CAPTCHAs, and so the technique will still not actually work reliably.

So, there is no general answer, other than to stop thinking that's a
race that you can win.

--
\ “DRM doesn't inconvenience [lawbreakers] — indeed, over time it |
`\ trains law-abiding users to become [lawbreakers] out of sheer |
_o__) frustration.” —Charles Stross, 2010-05-09 |
Ben Finney

Peter J. Holzer

unread,
May 29, 2018, 5:27:37 AM5/29/18
to
On 2018-05-24 09:59:14 +1000, Ben Finney wrote:
> If you are attempting to fool a CAPTCHA with an automated tool, you are
> entering an arms race against those who design the CAPTCHA to *prevent*
> exactly what you're doing.
>
> Any technique someone can describe to fool the CAPTCHA, will most likely
> already be considered as part of the design of the more effective
> CAPTCHAs, and so the technique will still not actually work reliably.

And any technique that someone can describe to fool programs will most
likely already be considered by those who write programs to break
captchas, and so the technique will still not actually work reliably.


> So, there is no general answer, other than to stop thinking that's a
> race that you can win.

I agree that there is no *general* answer. For any specific captcha,
there probably is a way to break it automatically, and possibly with
higher reliability than a human can (many captchas are hard and
frustrating for humans).

It *is* an arms race and who wins depends on who where to break-even
point between effort and value is for the defender and the attacker.

hp

--
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | h...@hjp.at | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
signature.asc
0 new messages