利用爬虫制作qq群发器
2018-12-17 本文已影响15人
真夜猫
qq群发器,让发送信息变的快捷高效,下面我们来切入正题。
附上群发效果图
1.JPG
2.JPG
qq群发器制作:
1.所需导入的库
from selenium import webdriver
import requests
import time
import urllib.request
2.网页版qq登陆url(目的:获取登陆cookie及好友id)
登陆
login_url="https://web2.qq.com/"
driver=webdriver.Chrome(executable_path='****\chromedriver.exe')
driver.get(login_url)
input("请进行扫码,等待网页加载完毕后按下回车键")
3.获取好友id
friend_list=[]
for eve_friend in driver.find_elements_by_class_name('list_item'):
friend_list.append(eve_friend.find_element_by_xpath('a').get_attribute('_uin'))
friend_list=list(set(friend_list))
print(friend_list)
4.获取并处理cookie信息
print(driver.get_cookies())
temp_cookie=""
for eve_cookie in driver.get_cookies():
temp_cookie=temp_cookie+eve_cookie['name'] + "=" + eve_cookie['value']+";"
5.将处理完的cookie放入headers
headers={
"accept": "*/*",
"accept-language": "zh-CN,zh;q=0.9",
"content-type": "application/x-www-form-urlencoded",
"cookie":temp_cookie,
"origin": "https://d1.web2.qq.com",
"referer": "https://d1.web2.qq.com/cfproxy.html?v=20151105001&callback=1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"
}
6.关闭浏览器
driver.quit()
7.利用post依次向好友发送信息(好友为我们获取的id)
while True:
info=input("请输入你要发送的话:")
for eve_friend in friend_list:
post_data={
"r": r'{"to":'+ str(eve_friend) +r',"content": "[\"'+str(info)+r'\",[\"font\",{\"name\":\"宋体\",\"size\":10,\"style\":[0,0,0],\"color\":\"000000\"}]]","face": 522, "clientid": 53999199, "msg_id": 12880001,"psessionid": "8368046764001d636f6e6e7365727665725f77656271714031302e3133332e34312e383400001ad00000066b026e040015808a206d0000000a406172314338344a69526d0000002859185d94e66218548d1ecb1a12513c86126b3afb97a3c2955b1070324790733ddb059ab166de6857"}'
}
print(requests.post(url="https://d1.web2.qq.com/channel/send_buddy_msg2",headers=headers,data=post_data))
到这里代码就结束了,qq群发器做好了,还等什么,快点去试试吧。