0

I am using mechanize python to login a website combochat2.us with username mask3 and pwd findnext, but it's showing an error like "no module found mechanize"

import cookielib  
import urllib2  
import mechanize   

# Browser  
br = mechanize.Browser()   
# Enable cookie support for urllib2  
cookiejar = cookielib.LWPCookieJar()  
br.set_cookiejar( cookiejar ) 

# Broser options  
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( mechanize._http.HTTPRefreshProcessor(), max_time = 1 )   
br.addheaders = [ ( 'User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1' ) ]   
# authenticate  
br.open(http://combochat2.us)  
br.select_form( name="combochat" )  

# these two come from the code you posted 
# where you would normally put in your username and password 
br[ "mask3" ] = yourLogin 
br[ "findnext" ] = yourPassword 
res = br.submit()   
print "Success!\n"   

I already installed the mechanize module.

Michael
  • 32,527
  • 49
  • 210
  • 370

2 Answers2

0

I do know how you installed Mechanize but try:

pip install mechanize

I had an issue fixed installing Mechanize this way.

0

mechanize supports only python 2.

Refer https://stackoverflow.com/a/31774959/4773973 for alternatives

Cibin
  • 590
  • 1
  • 7
  • 13