No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

42 líneas
1.8 KiB

  1. from urllib import parse
  2. import requests
  3. # 必须submit/test之后才能checklogic error (test即一次submit)
  4. # 从submit_id.txt中找到submit_id,填入referer
  5. # 从data.c找到代码,编码之后,填入url
  6. # get请求
  7. # 获得返回结果
  8. def check_logic_error() :
  9. file = open('data.c', mode='r', encoding='utf-8', newline='')
  10. code = file.read()
  11. file.close()
  12. code = parse.quote(code)
  13. print(code)
  14. url = "http://jf.shuishan.net.cn/api/code2vec?code=" + code
  15. print(url)
  16. file = open('submit_id.txt', mode='r', encoding='utf-8', newline='')
  17. submit_id = file.read()
  18. file.close()
  19. payload={}
  20. headers = {
  21. 'Host': 'jf.shuishan.net.cn',
  22. 'Connection': 'keep-alive',
  23. 'Accept': 'application/json, text/plain, */*',
  24. 'X-CSRFToken': '6eM4EeOzqLJFt6xfkbSMQD1e89qF28Lgg5aPIbB1k7Hvu6UFVzzb2d1u5lQG37p6',
  25. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36',
  26. 'Content-Type': 'application/json;charset=utf-8',
  27. 'Referer': 'http://jf.shuishan.net.cn/status/'+ submit_id,
  28. 'Accept-Encoding': 'gzip, deflate',
  29. 'Accept-Language': 'zh-CN,zh;q=0.9',
  30. 'Cookie': '_ga=GA1.3.1580759526.1611565238; _gid=GA1.3.412268444.1611565238; csrftoken=6eM4EeOzqLJFt6xfkbSMQD1e89qF28Lgg5aPIbB1k7Hvu6UFVzzb2d1u5lQG37p6; sessionid=0e47tlihcjyqr3oynpx5pq9xpf7jtqml; sessionid=0e47tlihcjyqr3oynpx5pq9xpf7jtqml'
  31. }
  32. response = requests.request("GET", url, headers=headers, data=payload)
  33. print(response.text)
  34. with open('check_logic_error.txt', 'w', encoding='utf-8', newline='') as f: # 设置文件对象
  35. f.write(response.text) # 将字符串写入文件中
  36. f.close()
  37. return response.text