使用python登陆dvbbs

2023-01-31 05:01:17 python 登陆 dvbbs
#! /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里不显示而已。
年纪大了,做事情反应不过来

相关文章