php js验证qq格式,php+js+mysql设计的仿webQQ-<2>其他验证

来看看其他验证是不是很简单啦!

<2>昵称验证

Js代码

function checkNickname(Nickname)

{

var xmlhttp;

if (window.XMLHttpRequest)

{// code for IE7+, Firefox, Chrome, Opera, Safari

xmlhttp=new XMLHttpRequest();

}

else

{// code for IE6, IE5

xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

}

xmlhttp.onreadystatechange=function()

{

if (xmlhttp.readyState==4 && xmlhttp.status==200)

{

document.getElementById("error2").innerHTML="*"; //复位

if(Nickname.length==0)

{

document.getElementById("error2").innerHTML="*昵称不能为空!";

}

else

{

if(Nickname.length>16)

{

document.getElementById("error2").innerHTML="*昵称不要超过16个字符!";

}

else

{

document.getElementById("error2").innerHTML="*昵称可用!";

}

}

}

}

xmlhttp.open("GET","index.php",true);

xmlhttp.send(); //注意这里与邮箱验证的不同

}

<3>密码验证

Js代码

function checkPwd1(password1)

{

var xmlhttp;

if (window.XMLHttpRequest)

{// code for IE7+, Firefox, Chrome, Opera, Safari

xmlhttp=new XMLHttpRequest();

}

else

{// code for IE6, IE5

xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

}

xmlhttp.onreadystatechange=function()

{

if (xmlhttp.readyState==4 && xmlhttp.status==200)

{ document.getElementById("error3").innerHTML="*";

document.getElementById("password2").value="";

document.getElementById("error4").innerHTML="*";

if(password1.length==0)

{

document.getElementById("error3").innerHTML="*密码不能为空!";

}

else

{

if(password1.length<6||password1.length>16)

{

document.getElementById("error3").innerHTML="*密码为6-16个字符!";

}

else

{

var reg=/[a-zA-Z0-9]/; //在js中使用正则表达式

if(reg.test(password1))

{

document.getElementById("error3").innerHTML="*密码可用!";

}

else

{

document.getElementById("error3").innerHTML="*密码不可用!";

}

}

}

}

}

xmlhttp.open("GET","index.php",true);

xmlhttp.send();

}

<4>重复密码验证

Js代码

function checkPwd2(password2)

{

var xmlhttp;

if (window.XMLHttpRequest)

{// code for IE7+, Firefox, Chrome, Opera, Safari

xmlhttp=new XMLHttpRequest();

}

else

{// code for IE6, IE5

xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

}

xmlhttp.onreadystatechange=function()

{

if (xmlhttp.readyState==4 && xmlhttp.status==200)

{ document.getElementById("error4").innerHTML="*";

if(password2.length==0)

{

document.getElementById("error4").innerHTML="*请确认密码!";

}

else

{

if(password2!=document.getElementById("password1").value)

{

document.getElementById("error4").innerHTML="*两次密码输入不一致!";

}

else

{

document.getElementById("error4").innerHTML="*密码输入一致!";

}

}

}

}

xmlhttp.open("GET","index.php",true);

xmlhttp.send();

}

怎么样,挺简单的吧!(未完待续)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
由于QQ聊天记录是需要登录QQ账号才能查看的,因此需要使用QQ的API或者模拟登录的方式来实现爬取聊天记录的功能。以下是使用模拟登录的方式实现的Python代码: ```python import requests from bs4 import BeautifulSoup # 登录QQ账号,并获取cookie def login_qq(username, password): login_url = 'https://xui.ptlogin2.qq.com/cgi-bin/xlogin' headers = { 'Referer': 'https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=715030901&daid=73&pt_no_auth=1&s_url=https%3A%2F%2Fid.qq.com%2Findex.html', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' } data = { 'u': username, 'p': password, 'verifycode': '', 'webqq_type': '40', 'remember_uin': '1', 'login2qq': '1', 'aid': '715030901', 'u1': 'https://id.qq.com/index.html', 'ptredirect': '0', 'h': '1', 'ptlang': '2052', 'daid': '73', 'from_ui': '1', 'pttype': '1', 'dumy': '', 'fp': 'loginerroralert', 'action': '0-35-1495675005110', 'mibao_css': 'm_webqq', 't': '1', 'g': '1', 'js_type': '0', 'js_ver': '10231', 'login_sig': '', 'pt_rsa': '0', 'pt_qzone_sig': '0', 'pt_vcode_v1': '0', 'pt_verifysession_v1': '', 'pt_randsalt': '2', 'pt_jstoken': '2040674265' } session = requests.Session() response = session.post(login_url, headers=headers, data=data) return session.cookies.get_dict() # 获取QQ聊天记录 def get_qq_chat_history(qq_number, cookie): chat_url = 'https://user.qzone.qq.com/proxy/domain/r.qzone.qq.com/cgi-bin/tfriend/qqchat_list_v2' headers = { 'Referer': 'https://user.qzone.qq.com/{}/infocenter'.format(qq_number), 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36', 'Cookie': 'uin=o{}; skey={}'.format(qq_number, cookie['skey']) } params = { 'uin': qq_number, 'start': 0, 'num': 10, 'cgi_host': 'http://m.qzone.qq.com/cgi-bin', 'callback': 'handleTList', 't': '0.4908397081636454', 'g_tk': '5381' } session = requests.Session() response = session.get(chat_url, headers=headers, params=params) soup = BeautifulSoup(response.text, 'html.parser') chats = soup.find_all('li', class_='list_item') for chat in chats: sender = chat.find('a', class_='sender').text.strip() content = chat.find('div', class_='content').text.strip() print('{}: {}'.format(sender, content)) # 测试代码 if __name__ == '__main__': qq_number = '123456789' # QQ号码 username = 'your_qq_username' # 登录QQ账号 password = 'your_qq_password' # 登录QQ密码 cookie = login_qq(username, password) # 登录QQ账号,并获取cookie get_qq_chat_history(qq_number, cookie) # 获取QQ聊天记录 ``` 上述代码中,`login_qq`函数用于模拟登录QQ账号,并获取cookie信息;`get_qq_chat_history`函数用于获取QQ聊天记录。通过调用这两个函数,即可实现获取QQ聊天记录的功能。需要注意的是,QQ聊天记录的获取需要登录QQ账号,因此需要提供正确的QQ账号和密码。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值