I need to press a button which has this code:
"<a href="/follows?followed_id=101769" class="js-toggle-follow btn-social btn-follow data-method="post" data-remote="true" id="follow" rel="nofollow">"
The button doesn't have "name" and I don't know how to find it using "id" and then click.
I'm using Python with Mechanize. In the coment pulsar enlace i want to click the button and then forwards to next user.
This is the script:
import mechanize
import cookielib
import sys
import os
url= "http://web.com/users/sign_in"
br = mechanize.Browser()
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
br.set_handle_robots(False)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; es-VE; rv:1.9.0.1)Gecko/2008071615 Debian/6.0 Firefox/9')]
r=br.open(url)
br.select_form(nr=2)
br.form['user[login]'] = '@hotmail.com'
br.form['user[password]'] = '123123'
os.system('clear')
try:
print "Loggin....."
br.submit()
except:
print "Logued failed..."
sys.exit()
print "Logued Succesfully!!!"
i=0
ok=0
url77="http://web.com"
enlaceexiste = False
usuarioexiste = False
while i < 100000:
try:
br.open(url77+"/users/"+str(i))
print "Accessing "+url77+"/users/"+str(i)
usuarioexiste = True
except:
print "User "+str(i)+" failed..."
usuarioexiste = False
enlaceexiste = False
if usuarioexiste:
try:
enlace = br.find_link(text='Seguir')
enlaceexiste = True
print enlace
except:
print "No follow button!"
enlaceexiste = False
if enlaceexiste:
try:
#pulsar enlace
ok+=1
print "\tTotal users followed and challenged: "+str(ok)
except:
print "\tCant follow user "+str(i)
i+=1
enlaceexiste = False
i+=1
print "All users finished!!!"