Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用Python连接vBulletin 4.2.2论坛_Python_Vb.net_Md5_Vbulletin - Fatal编程技术网

用Python连接vBulletin 4.2.2论坛

用Python连接vBulletin 4.2.2论坛,python,vb.net,md5,vbulletin,Python,Vb.net,Md5,Vbulletin,我读了这一页,代码仍然不起作用: 我的代码: #-*- coding:utf-8 -*- import urllib, urllib2, cookielib, hashlib, time def variables(): domain = "www.example.com" uname = "UserName" passwd = "Password" # Create url if domain.startswith('http://'):

我读了这一页,代码仍然不起作用:

我的代码:

#-*- coding:utf-8 -*-

import urllib, urllib2, cookielib, hashlib, time

def variables():
    domain = "www.example.com"
    uname = "UserName"
    passwd = "Password"

    # Create url
    if domain.startswith('http://'):
         url = domain
    else:
        url = 'http://' + domain

    login(url, uname, passwd)


def login(url, uname, passwd):
    loginurl = url + '/login.php?do=login'
    md5 = hashlib.md5(passwd);md5 = md5.hexdigest()
    # Options for request
    opts = {
        'do': 'login',
        'vb_login_md5password': md5,
        'vb_login_md5password_utf': md5,
        's': '',
        'vb_login_username': uname, 
        'security_token': 'guest', 
    }
    data = urllib.urlencode(opts)

    # Request header
    global headers
    headers = {
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Accept-Language': 'es-es,es;q=0.8,en-us;q=0.5,en;q=0.3',
        'Accept-Encoding': 'gzip,deflate',
        'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
        'Connection': 'keep-alive',
        'Referer': loginurl,
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Lenght': '205'
    }

    # Cookie Handling
    jar = cookielib.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

    # Send Request
    opener.addheader = headers
    opener.open(loginurl, data)

    # Check
    response = opener.open('http://example.com/')
    source_code = response.read()
    if source_code.find(uname) != -1:
        print "Login Succeeded."
    else:
        print "Login Failed."


variables()
字段名的属性值为无(空):


为什么代码不起作用

谢谢。

缺少的“vb\u登录密码”、“vb\u登录密码提示”、“cookieuser”和“vb\u登录md5password\u utf”必须为空


并删除您的标题。

我应该在vb\u登录\u密码\u提示和cookieuser中输入什么?如果你能给我一个代码示例,这将非常有用。安装Live HTTP头(只有firefox可以工作)并打开它,然后开始登录,你将看到所有POST请求。我在firefox中安装了Live HTTP头,并在开始登录之前打开它,我看到了所有POST请求,之后我相应地填写了所有输入表单,我试图再次登录,但没有成功。怎么了?我成功地登录了论坛,但有时它会工作,在运行了三次脚本之后,它就不再登录了。什么问题?我怎样才能修好它?
<input type="hidden" name="s" value="" />