main
CustomerAcquisition 6 months ago
parent 8c687d20b1
commit 771692052c

@ -4,15 +4,16 @@ import message_pb2 # 导入生成的 Protobuf 文件
# 设置请求的 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"
'verifyFp':' verify_lwlm1u72_stNCFCId_qzbH_4cpL_9Iep_AqW2XPQog7ma',
'fp':' verify_lwlm1u72_stNCFCId_qzbH_4cpL_9Iep_AqW2XPQog7ma',
'msToken':' njIGDLHr2aThtqWR71HS4Y1ueT_70s5l3zBQOR9qBlRIUVD__dCr1lCU6-jQ-Ht21YTiTma7ijS07tWK1u3oyLpq6W-1x3Y0wPgWpovAnBwnIuRKp-aDcZDv',
'a_bogus':' dX8qQQLDdDVsvDy65XoLfY3q66l3Y0LC0trEMD2f6dfP9y39HMOy9exEVi4vgrmjLG%2FlIeSjy4hbYN9krQVrMZwfHuix%2F2ohmDSkKl5Q598Ss1XrejusrziNmkwUSaBB5JrlrO0MqJKcFmjp09oj4vIlO6ZCcHgOEisnOcf%3D',
}
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",
'Referer':'https://www.douyin.com/',
"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; 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; 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; pwa2=%220%7C0%7C3%7C0%22; EnhanceDownloadGuide=%220_0_0_0_1_1717338361%22; FOLLOW_NUMBER_YELLOW_POINT_INFO=%22MS4wLjABAAAAsHY3M7WCvAd6-fwDR0tYP32MvxlSPgEfD3dF69gvt3Wg7bkb3YHFIkTg0hifLIWT%2F1717430400000%2F0%2F1717401960885%2F0%22; FOLLOW_LIVE_POINT_INFO=%22MS4wLjABAAAAsHY3M7WCvAd6-fwDR0tYP32MvxlSPgEfD3dF69gvt3Wg7bkb3YHFIkTg0hifLIWT%2F1717430400000%2F1717350202922%2F1717404165600%2F0%22; strategyABtestKey=%221717404166.274%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%3A1%7D%22; WallpaperGuide=%7B%22showTime%22%3A1717401975356%2C%22closeTime%22%3A0%2C%22showCount%22%3A3%2C%22cursor1%22%3A99%2C%22cursor2%22%3A0%2C%22hoverTime%22%3A1717256760346%7D; FRIEND_NUMBER_RED_POINT_INFO=%22MS4wLjABAAAAsHY3M7WCvAd6-fwDR0tYP32MvxlSPgEfD3dF69gvt3Wg7bkb3YHFIkTg0hifLIWT%2F1717430400000%2F1717404179615%2F0%2F0%22; 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%3A150%7D%22; bd_ticket_guard_client_data=eyJiZC10aWNrZXQtZ3VhcmQtdmVyc2lvbiI6MiwiYmQtdGlja2V0LWd1YXJkLWl0ZXJhdGlvbi12ZXJzaW9uIjoxLCJiZC10aWNrZXQtZ3VhcmQtcmVlLXB1YmxpYy1rZXkiOiJCTlplYVlVb2N5Z1ZqakNXYnptL0RNN1h6OE94VWJ6ZVVETkFBWVVvRFJEMlJTSkxFRkJQOVhjazlCSzd6K0dUMzBnTlBwKzlwWnZ6a0hoQXRrWEdabUE9IiwiYmQtdGlja2V0LWd1YXJkLXdlYi12ZXJzaW9uIjoxfQ%3D%3D; home_can_add_dy_2_desktop=%221%22; IsDouyinActive=true; msToken=PDM8f5xVkS9ANmYq5ON7QACu4h6gyn__7GD9eHaebO4Amp3v7q1ZBtyJ3IHI9pNo1icrTMron2vZOxmqk4rZnpzxftVr6-OigF9At740-17wLY8evKYl0lg4; odin_tt=ab8011d63e720b24d5199544f9aacd46c4a278f88faea1e9a86ed5e41a682d6b344219cd7fae6bebf56a2f8ca7172fd25723d72ca840fed8d32fc4826bcc203d",
"Content-Type": "application/x-protobuf",
"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"
}
@ -20,7 +21,7 @@ headers = {
# 创建 Message 对象并填充数据
message = message_pb2.Message()
message.content = "你好,这是一条测试私信"
message.account = "zy2752629612"
message.account = "dyvqzj2v7yv9"
# 将 Message 对象序列化为字节
data = message.SerializeToString()
@ -34,5 +35,5 @@ response = requests.post(url, headers=headers, params=params, data=data)
print(response.status_code)
print(response.text)
print(response.headers)
print(response.content)
# print(response.headers)
# print(response.content)

@ -8,66 +8,88 @@ 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("--headless")
options.add_argument("--start-maximized") # 最大化窗口
options.add_argument("--disable-notifications") # 禁用通知
options.headless = True
options.add_argument("user-data-dir=C:/Users/JJM/AppData/Local/Microsoft/Edge/User Data/Default") # 使用本地用户数据目录
options= webdriver.EdgeOptions()
options.add_experimental_option("detach", True)
driver_edge = webdriver.Edge(options=options)
cookies = driver_edge.get_cookies()
for cookie in cookies:
print(cookie)
my_url = "https://www.douyin.com/"
driver_edge.get(my_url)
sleep(70)
sleep(5)
# 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)
# 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)
search_box = driver_edge.find_element(By.XPATH,'//input[@class="st2xnJtZ YIde9aUh"]')
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, "//*")
print(search_box)
search_box.send_keys('zy2752629612',Keys.ENTER)
sleep(5)
print('===========>111111111')
handles = driver_edge.window_handles #获取当前浏览器的所有窗口句柄
driver_edge.switch_to.window(handles[-1])
divm = driver_edge.find_element(By.XPATH,'//div[@class="G8LTciwG"]/a')
divm.click()
print('==============66666')
# sleep(10)
# driver_edge.execute_script("window.scrollTo(0, document.body.scrollHeight);")
# sleep(1) # 等待滚动效果
#f=driver_edge.find_element(By.CLASS_NAME,'B3AsdZT9 BMJLsW6X').click()
# elements = driver_edge.find_elements(By.XPATH, "//*")
# print(elements)
# 检查每个元素是否可见
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("元素仍不可见")
# 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, 1).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(1) # 等待滚动效果
# # 再次检查元素是否可见
# 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]')
handles = driver_edge.window_handles #获取当前浏览器的所有窗口句柄
driver_edge.switch_to.window(handles[-1])
print('==============66666')
h=driver_edge.find_element(By.XPATH,'//div[@class="hLIm2dFu"]/button[2]')
h.click()
# 获取cookie
cookies = driver_edge.get_cookies()
for cookie in cookies:
print(cookie)
b=driver_edge.find_element(By.XPATH,'//div[@class="c8uBfaOs"]/div[@class="public-DraftEditorPlaceholder-inner"]')
b.send_keys('zy2752629612',Keys.ENTER)
# 关闭浏览器
driver_edge.quit()
# # 关闭浏览器
# driver_edge.quit()
Loading…
Cancel
Save