打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
自动登录程序python实现



# coding=utf8

"""

这个Python脚本用于登录北科大校园网,修改文件中的usernamepassword后,将文件

放到启动项中,就可以实现开机自动登录校园网了。

Python版本:2.7.2

"""

 

import httplib

import subprocess

import re

 

def get_Local_ipv6_address():

   """

    Thisfunction will return your local machine's ipv6 address if itexits.

    Ifthe local machine doesn't have a ipv6 address,then this functionreturn None.

    Thisfunction use subprocess to execute command "ipconfig", thenget the output

    anduse regex to parse it ,trying to  find ipv6address.

   """

   getIPV6_process = subprocess.Popen("ipconfig", stdout = subprocess.PIPE)

   output = (getIPV6_process.stdout.read())

   ipv6_pattern='(([a-f0-9]{1,4}:){7}[a-f0-9]{1,4})'

    m =re.search(ipv6_pattern, str(output))

   if m is not None:

       return m.group()

   else:

       return None

   

#请将usernamepassword修改成自己真实的校园网账户和密码

username='40150xxx'

password='xxxxxx'

 

headers = {"Connection": "keep-alive",

          "Cookie": "myusername=%s; username=%s;smartdot=%s" %(username, username, password)}

body = "DDDDD=%s&upass=%s&0MKKey=123456789&v6ip=%s"%(username,password,get_Local_ipv6_address())

conn = httplib.HTTPConnection("202.204.48.82")

conn.request("POST", "/",body = body,headers = headers)

response = conn.getresponse()

print response.status, response.reason

来自:http://blog.sina.com.cn/s/blog_3fe961ae0100p7rk.html

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
北科大校园网自动登录Python实现(win7版)
利用python脚本自动登录华农校园网(附程序)
python中常用的各种数据库操作模块和连接实例
简单的连接MySQL与Python的Bottle框架的方法
使用Python读写Hive:简化大数据处理的利器
Pydantic 初学者指南
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服