CustomerAcquisition 6 months ago
parent c143ca8a02
commit 8c687d20b1

@ -0,0 +1,8 @@
from grpc_tools import protoc
protoc.main((
'',
'-I.', # Import paths
'--python_out=.', # Output directory
'message.proto', # Proto file
))

@ -1,47 +1,38 @@
from tkinter import*
import requests
import message_pb2 # 导入生成的 Protobuf 文件
user_login ={'aaa':'123456', 'bbb':'888888', 'ccc':'333333', }
# 设置请求的 URL 和参数
url = "https://imapi.douyin.com/v1/message/send"
params = {
"msToken": "AoiVI_ZJ9bOmevnFussZoK-JLQjouxwc8WV1n-sMFe2PgALgCivMbdZxnCD2iKI5yNv43ITDA9DNJsiCFV4U1xtFCfzh8T4SiDVakD_4ekKnJ2XtsGYD61h4",
"a_bogus": "O7m0QDuhdifpgfyv5X9LfY3q6633Ym%2Fv0trEMD2fxdfl3g39HMT49exY3Pwvi06jLG%2FlIeyjy4hbYN9krQ%2FH0HwfHuix%2F2ohmDSkKl5Q59Dc-NineggME0hi4kb3tMrQsv1UxOfkohIaSYuplIqe5XclbfebYrtswnuYt9%2Fb5D%3D%3D",
"verifyFp": "verify_lwlm1u72_stNCFCId_qzbH_4cpL_9Iep_AqW2XPQog7ma",
"fp": "verify_lwlm1u72_stNCFCId_qzbH_4cpL_9Iep_AqW2XPQog7ma"
}
#定义登录次数
count =0
def login():
global count
username =entry_username.get ()
if username not in user_login:
label_message.config(text='账号错误!')
else:
password =entry_password.get ()
if (password ==user_login[username]):
label_message.config(text='登录成功!')
open_new_window()
else:
label_message.config(text='密码错误!还可以尝试{}'.format (2 -coum))
count = count +1
if count ==3:
label_message.config(text='登录失败!')
btn_login.config(state="disabled")
def open_new_window():
# 创建一个新窗口
new_window = Toplevel(window)
new_window.title("登录成功")
new_window.geometry("300x200")
Label(new_window, text="欢迎进入新页面!").pack()
window =Tk()
window.title("用户登录")
window.geometry("300x200")
#创建标签和输入框
label_username=Label(window, text="账号:")
label_username.pack()
entry_username =Entry (window)
entry_username.pack ()
label_password=Label (window, text="密码:")
label_password.pack ()
entry_password = Entry(window, show='*')
entry_password.pack()
#创建登录按钮和消息提示标签
btn_login =Button (window, text="登录", command=login)
btn_login.pack()
label_message = Label (window, text ="")
label_message.pack()
#运行主循环
window.mainloop ()
headers = {
"Cookie":"LOGIN_STATUS=1; store-region=cn-hn; store-region-src=uid; my_rd=2; __live_version__=%221.1.1.4879%22; ttwid=1%7Cj1y2rrK1xocvz8_dWNVIq9GJ1UUkc3qyI3unO5Hnz7c%7C1710497985%7C0580bd3d607011ab36c5240383d9941e485699343a9be647cab7b4e4877837e3; bd_ticket_guard_client_web_domain=2; SEARCH_RESULT_LIST_TYPE=%22single%22; passport_csrf_token=58820e3ccfd2a4c8d213c627c8bfcbf2; passport_csrf_token_default=58820e3ccfd2a4c8d213c627c8bfcbf2; FORCE_LOGIN=%7B%22videoConsumedRemainSeconds%22%3A180%2C%22isForcePopClose%22%3A1%7D; _bd_ticket_crypt_doamin=2; __security_server_data_status=1; download_guide=%223%2F20240525%2F1%22; volume_info=%7B%22isUserMute%22%3Afalse%2C%22isMute%22%3Atrue%2C%22volume%22%3A0.782%7D; FOLLOW_NUMBER_YELLOW_POINT_INFO=%22MS4wLjABAAAAsHY3M7WCvAd6-fwDR0tYP32MvxlSPgEfD3dF69gvt3Wg7bkb3YHFIkTg0hifLIWT%2F1717171200000%2F0%2F1717115163191%2F0%22; strategyABtestKey=%221717302723.411%22; stream_player_status_params=%22%7B%5C%22is_auto_play%5C%22%3A1%2C%5C%22is_full_screen%5C%22%3A0%2C%5C%22is_full_webscreen%5C%22%3A0%2C%5C%22is_mute%5C%22%3A1%2C%5C%22is_speed%5C%22%3A1%2C%5C%22is_visible%5C%22%3A0%7D%22; passport_assist_user=CkGTU8poo6Xij7PpTE-fUre1nhzcRBFJYHRkb7NQSNTQ9iNdua_sq5fW3SH3UswucQWWgGMnSPMP1bB1ILAbFI0CWBpKCjxGylE8zOMF-zm4w_eR6Pi_pX-ZzeDFKYIrlSqAG5E4ICB0TXX9rIwP8tdroe8GAZc1jHqmwTdNPdMWwSIQp_nSDRiJr9ZUIAEiAQN-VLfr; n_mh=eRTYt2yhIheBvqQdvgMfXadK0QnaYOp5didcMz0Ww-o; sso_uid_tt=9ed08f5e09478ad14f5c7040302e1eb9; sso_uid_tt_ss=9ed08f5e09478ad14f5c7040302e1eb9; toutiao_sso_user=f9d9c4f781e3bab9ac19a8f4a3100824; toutiao_sso_user_ss=f9d9c4f781e3bab9ac19a8f4a3100824; sid_ucp_sso_v1=1.0.0-KDkyYTIxMjA2MDJiYTc2MWVkMzg2MzZkMDViMGZmMDY2ZmE5MjA4N2IKHwjUmfCgqMzoAhDZgPKyBhjvMSAMMNmDoaEGOAZA9AcaAmxxIiBmOWQ5YzRmNzgxZTNiYWI5YWMxOWE4ZjRhMzEwMDgyNA; ssid_ucp_sso_v1=1.0.0-KDkyYTIxMjA2MDJiYTc2MWVkMzg2MzZkMDViMGZmMDY2ZmE5MjA4N2IKHwjUmfCgqMzoAhDZgPKyBhjvMSAMMNmDoaEGOAZA9AcaAmxxIiBmOWQ5YzRmNzgxZTNiYWI5YWMxOWE4ZjRhMzEwMDgyNA; passport_auth_status=d9b57afe2b5a9d46bf94fe6be3fbff5e%2Ce86684cdf98b870d7eccf74c2242c1fc; passport_auth_status_ss=d9b57afe2b5a9d46bf94fe6be3fbff5e%2Ce86684cdf98b870d7eccf74c2242c1fc; uid_tt=0f66b8fa9bc5d113e984d09b1d834684; uid_tt_ss=0f66b8fa9bc5d113e984d09b1d834684; sid_tt=d8a420e331706f83d5ca7c6ee82cd4c8; sessionid=d8a420e331706f83d5ca7c6ee82cd4c8; sessionid_ss=d8a420e331706f83d5ca7c6ee82cd4c8; publish_badge_show_info=%220%2C0%2C0%2C1717338205811%22; _bd_ticket_crypt_cookie=4dbd1a3b0950e14f64ff55ec49f90e45; FOLLOW_LIVE_POINT_INFO=%22MS4wLjABAAAAsHY3M7WCvAd6-fwDR0tYP32MvxlSPgEfD3dF69gvt3Wg7bkb3YHFIkTg0hifLIWT%2F1717344000000%2F0%2F1717338206814%2F0%22; sid_guard=d8a420e331706f83d5ca7c6ee82cd4c8%7C1717338207%7C5183997%7CThu%2C+01-Aug-2024+14%3A23%3A24+GMT; sid_ucp_v1=1.0.0-KDg2ZGFkNmFhM2M3NTkzZDg2Yjk1YjVkMTkxYjU1NWZmNjVhMThjZTYKGwjUmfCgqMzoAhDfgPKyBhjvMSAMOAZA9AdIBBoCbGYiIGQ4YTQyMGUzMzE3MDZmODNkNWNhN2M2ZWU4MmNkNGM4; ssid_ucp_v1=1.0.0-KDg2ZGFkNmFhM2M3NTkzZDg2Yjk1YjVkMTkxYjU1NWZmNjVhMThjZTYKGwjUmfCgqMzoAhDfgPKyBhjvMSAMOAZA9AdIBBoCbGYiIGQ4YTQyMGUzMzE3MDZmODNkNWNhN2M2ZWU4MmNkNGM4; stream_recommend_feed_params=%22%7B%5C%22cookie_enabled%5C%22%3Atrue%2C%5C%22screen_width%5C%22%3A1280%2C%5C%22screen_height%5C%22%3A720%2C%5C%22browser_online%5C%22%3Atrue%2C%5C%22cpu_core_num%5C%22%3A8%2C%5C%22device_memory%5C%22%3A8%2C%5C%22downlink%5C%22%3A10%2C%5C%22effective_type%5C%22%3A%5C%224g%5C%22%2C%5C%22round_trip_time%5C%22%3A100%7D%22; home_can_add_dy_2_desktop=%221%22; bd_ticket_guard_client_data=eyJiZC10aWNrZXQtZ3VhcmQtdmVyc2lvbiI6MiwiYmQtdGlja2V0LWd1YXJkLWl0ZXJhdGlvbi12ZXJzaW9uIjoxLCJiZC10aWNrZXQtZ3VhcmQtcmVlLXB1YmxpYy1rZXkiOiJCTlplYVlVb2N5Z1ZqakNXYnptL0RNN1h6OE94VWJ6ZVVETkFBWVVvRFJEMlJTSkxFRkJQOVhjazlCSzd6K0dUMzBnTlBwKzlwWnZ6a0hoQXRrWEdabUE9IiwiYmQtdGlja2V0LWd1YXJkLXdlYi12ZXJzaW9uIjoxfQ%3D%3D; pwa2=%220%7C0%7C3%7C0%22; EnhanceDownloadGuide=%220_0_0_0_1_1717338361%22; WallpaperGuide=%7B%22showTime%22%3A1717115344302%2C%22closeTime%22%3A0%2C%22showCount%22%3A2%2C%22cursor1%22%3A87%2C%22cursor2%22%3A0%2C%22hoverTime%22%3A1717256760346%7D; IsDouyinActive=true; odin_tt=0c1b76b619783e164cbdd74c05a22102308e30af152dab51f189b1296a77442258e490210ad3b456231f0da4fc18490646eb3d5336bb6c5d08e1fe173fad8245; msToken=te2BFr5x25GZ0vk_n_SwxDXxJjmSkhD2_MZUHamuw6HbQ2PEy-sPXbnV9qdYcg2mYrsjRVdFXw7z42veNMQuQ1bY5yTbaW0q1Z7QuPyXLG0fKjYnYt2VEpdB",
"Content-Type": "application/octet-stream",
"Accept": "application/x-protobuf",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0"
}
# 创建 Message 对象并填充数据
message = message_pb2.Message()
message.content = "你好,这是一条测试私信"
message.account = "zy2752629612"
# 将 Message 对象序列化为字节
data = message.SerializeToString()
print(data)
print(len(data))
# 发送请求
response = requests.post(url, headers=headers, params=params, data=data)
# 输出响应状态码和内容
print(response.status_code)
print(response.text)
print(response.headers)
print(response.content)

@ -0,0 +1,6 @@
syntax = "proto3";
message Message {
string content = 1;
string account = 2;
}

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: message.proto
# Protobuf Python Version: 5.26.1
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\rmessage.proto\"+\n\x07Message\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t\x12\x0f\n\x07\x61\x63\x63ount\x18\x02 \x01(\tb\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'message_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
_globals['_MESSAGE']._serialized_start=17
_globals['_MESSAGE']._serialized_end=60
# @@protoc_insertion_point(module_scope)

@ -1,12 +1,12 @@
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
options = webdriver.EdgeOptions()
options.add_argument("--start-maximized") # 最大化窗口
options.add_argument("--disable-notifications") # 禁用通知
@ -20,21 +20,48 @@ driver_edge = webdriver.Edge(options=options)
my_url = "https://www.douyin.com/"
driver_edge.get(my_url)
sleep(11)
sleep(70)
x=driver_edge.find_element(By.XPATH,'//*[@id="login-pannel"]/div[2]')
x.click()
sleep(10)
# x=driver_edge.find_element(By.XPATH,'//*[@id="login-pannel"]/div[2]')
# x.click()
# sleep(10)
# 模拟点击
search_box = driver_edge.find_element(By.XPATH,'//*[@id="douyin-header"]/div[1]/header/div/div/div[1]/div/div[2]/div/div/input').send_keys('zy2752629612',Keys.ENTER)
sleep(15)
sleep(20)
driver_edge.execute_script("window.scrollTo(0, document.body.scrollHeight);")
sleep(10) # 等待滚动效果
#f=driver_edge.find_element(By.CLASS_NAME,'B3AsdZT9 BMJLsW6X').click()
elements = driver_edge.find_elements(By.XPATH, "//*")
s=driver_edge.find_element(By.XPATH,'//*[@id="search-content-area"]/div/div[1]/div[2]/div[1]/ul/li/div/div/div/div/div/a')
s.click()
sleep(5)#/html/body/div[2]/div/div[2]/div[2]/div/div[1]/div[2]/div[1]/ul/li/div/div/div/div/div/a//*[@id="search-content-area"]/div/div[1]/div[2]/div[1]/ul/li/div/div/div/div/div/a
# 检查每个元素是否可见
for element in elements:
if element.is_displayed():
print(f"元素 {element.tag_name} 可见")
else:
print(f"元素 {element.tag_name} 不可见")
driver_edge.execute_script("arguments[0].style.display = 'block'; arguments[0].style.visibility = 'visible';", element)
try:
# 等待元素可见超时设置为5秒
WebDriverWait(driver_edge, 5).until(
EC.visibility_of(element)
)
print(f"元素 {element.tag_name} 现在可见")
except TimeoutException:
print(f"元素 {element.tag_name} 仍然不可见")
driver_edge.execute_script("arguments[0].scrollIntoView(true);", element)
sleep(10) # 等待滚动效果
# 再次检查元素是否可见
if element.is_displayed():
print("元素现在可见")
else:
print("元素仍不可见")
sleep(10)
h=driver_edge.find_element(By.XPATH,'//*[@id="douyin-right-container"]/div[2]/div/div/div[2]/div[3]/div[3]/div[1]/button[2]')
h.click()
# 获取cookie

Loading…
Cancel
Save