You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
5.7 KiB

6 months ago
import requests
import message_pb2 # 导入生成的 Protobuf 文件
6 months ago
6 months ago
# 设置请求的 URL 和参数
url = "https://imapi.douyin.com/v1/message/send"
params = {
6 months ago
'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',
6 months ago
}
6 months ago
6 months ago
headers = {
6 months ago
'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=eyJiZC10aWNrZXQtZ3VhcmQtdmVyc2lvbiI6MiwiYmQtdGlja2V0LWd1YXJkLWl0ZXJhdGlvbi12ZXJzaW9uIjoxLCJiZC10aWNrZXQtZ3VhcmQtcmVlLXB1YmxpYy1rZXkiOiJCTlplYVlVb2N5Z1ZqakNXYnptL0RNN1h6OE94VWJ6ZVVETkFBWVVvRFJEMlJTSkxFRkJQOVhjazlCSzd6K0dUMzBnTlBwKzlwWnZ6a0hoQXRrWEdabUE9IiwiY
"Content-Type": "application/x-protobuf",
6 months ago
"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 = "你好,这是一条测试私信"
6 months ago
message.account = "dyvqzj2v7yv9"
6 months ago
# 将 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)
6 months ago
# print(response.headers)
# print(response.content)