使用python登陆dvbbs

发布时间:2019-09-07 08:12:51编辑:auto阅读(1707)

    #! /usr/bin/env python
    #coding=utf-8
    import urllib,httplib
    params = urllib.urlencode({'username':'admin',              #此处为要post的登陆参数,你可以修改为你自己的参数
                                             'password':'password',
                                             'CookieDate': 1,
                                             'userhidden':2})
    headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
                                                                                        #构建headers
    conn = httplib.HTTPConnection("x.x.x.x:80")   #建立http连接,记得地址不要加'http://'且要加上port
    conn.request("POST",'/login.asp?action=chk', params, headers)
                                                                                        #发送登陆请求
    response = conn.getresponse()                                      #获得回复
    print response.status, response.reason                           #获得请求状态
    data = response.read()
    print data                                                 #获得登陆后的网页内容
    conn.close()  
     
    忙了两天,就是搞这个,
    从网上找了不少代码,一个个试,最后还是把python的英文帮助拿来看,终于看明白了
    原来我早就搞好了,已经登陆了,只是ie里不显示而已。
    年纪大了,做事情反应不过来

关键字