我正在使用 mechanize python 登录网站 combochat2.us
用户名 mask3
和密码findnext
,但它显示了“没有找到 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"
我已经安装了 Mechanize 模块。
最佳答案
我知道你是如何安装 Mechanize 但试试:
pip install mechanize
我在以这种方式安装 Mechanize 时遇到了问题。
关于mechanize - Mechanize python中的模块错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30036324/