how to handle captcha through machanize module or any module

J

Jai

#/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)]="(e-mail address removed)"
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
 
R

Robert Kern

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
 
J

Joel Goldstick

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.
 
C

Chris Angelico

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
 
M

Michael Torrie

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.
 
M

Mark Lawrence

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 :(
 
J

Joel Goldstick

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.
 
D

Denis McMahon

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top