|
|
- from urllib import parse
- import requests
- # 必须submit/test之后才能checklogic error (test即一次submit)
- # 从submit_id.txt中找到submit_id,填入referer
- # 从data.c找到代码,编码之后,填入url
- # get请求
- # 获得返回结果
- def check_logic_error() :
- file = open('data.c', mode='r', encoding='utf-8', newline='')
- code = file.read()
- file.close()
-
- code = parse.quote(code)
- print(code)
- url = "http://jf.shuishan.net.cn/api/code2vec?code=" + code
- print(url)
- file = open('submit_id.txt', mode='r', encoding='utf-8', newline='')
- submit_id = file.read()
- file.close()
-
- payload={}
- headers = {
- 'Host': 'jf.shuishan.net.cn',
- 'Connection': 'keep-alive',
- 'Accept': 'application/json, text/plain, */*',
- 'X-CSRFToken': '6eM4EeOzqLJFt6xfkbSMQD1e89qF28Lgg5aPIbB1k7Hvu6UFVzzb2d1u5lQG37p6',
- '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',
- 'Content-Type': 'application/json;charset=utf-8',
- 'Referer': 'http://jf.shuishan.net.cn/status/'+ submit_id,
- 'Accept-Encoding': 'gzip, deflate',
- 'Accept-Language': 'zh-CN,zh;q=0.9',
- 'Cookie': '_ga=GA1.3.1580759526.1611565238; _gid=GA1.3.412268444.1611565238; csrftoken=6eM4EeOzqLJFt6xfkbSMQD1e89qF28Lgg5aPIbB1k7Hvu6UFVzzb2d1u5lQG37p6; sessionid=0e47tlihcjyqr3oynpx5pq9xpf7jtqml; sessionid=0e47tlihcjyqr3oynpx5pq9xpf7jtqml'
- }
-
- response = requests.request("GET", url, headers=headers, data=payload)
-
- print(response.text)
- with open('check_logic_error.txt', 'w', encoding='utf-8', newline='') as f: # 设置文件对象
- f.write(response.text) # 将字符串写入文件中
- f.close()
- return response.text
-
|