1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| import requests_html import re import json
url = "http://stu.ityxb.com/back/bxg/my/busywork/findStudentBusywork?busyworkId=166955876c3b4bcf8ef39976dfe60e76&t=1608445306731" url2 = 'http://stu.ityxb.com/back/bxg/my/busywork/findStudentBusywork?busyworkId=655d240321db424ea37f4b55c2f132d2&t=1608476055939'
headers = { 'User-Agent': '', 'Cookie': '' }
res = requests_html.HTMLSession() r = res.get(url2, headers=headers)
text = json.loads(r.text) text_xz = text['resultObject']["danxuan"]['lists'] neirong = {}
for i in range(1, len(text_xz) + 1): wenzi = text_xz.pop(0) text_xx = wenzi["questionOptionList"] text_tm = str(i) + '.' + wenzi["questionContentText"] print(text_tm) with open('jsdx.text', 'a', encoding='utf-8') as f: f.write('\n' + text_tm) for num in range(len(text_xx)): xx_dan = text_xx.pop(0) xx_nei = xx_dan['text'] with open('jsdx.text', 'a', encoding='utf-8') as f: f.write('\n' + xx_nei) with open('jsdx.text', 'a', encoding='utf-8') as f: f.write('\n' + '答案:') try: text_xz = text['resultObject']["duoxuan"]['lists'] for i in range(1, len(text_xz) + 1): wenzi = text_xz.pop(0) text_xx = wenzi["questionOptionList"] text_tm = str(i) + '.' + wenzi["questionContentText"] print(text_tm) with open('jsdx.text', 'a', encoding='utf-8') as f: f.write('\n' + text_tm) for num in range(len(text_xx
)): xx_dan = text_xx.pop(0) xx_nei = xx_dan['text'] with open('jsdx.text', 'a', encoding='utf-8') as f: f.write('\n' + xx_nei) with open('jsdx.text', 'a', encoding='utf-8') as f: f.write('\n' + '答案:') except: pass
try: text_pd = text['resultObject']["panduan"]['lists'] for i in range(1, len(text_pd) + 1): wenzi = text_pd.pop(0) text_tm = str(i) + '.' + wenzi["questionContentText"] print(text_tm) with open('jsdx.text', 'a', encoding='utf-8') as f: f.write('\n' + text_tm + '\n' + '答案:') except: pass
try: text_tk = text['resultObject']["tiankong"]['lists'] for i in range(1, len(text_tk) + 1): wenzi = text_tk.pop(0) text_tm = str(i) + '.' + wenzi["questionContentText"] print(text_tm) with open('jsdx.text', 'a', encoding='utf-8') as f: f.write('\n' + text_tm + '\n' + '答案:') except: pass
try: text_jd = text['resultObject']["jianda"]['lists'] for i in range(1, len(text_jd) + 1): wenzi = text_jd.pop(0) text_tm = str(i) + '.' + wenzi["questionContentText"] print(text_tm) with open('jsdx.text', 'a', encoding='utf-8') as f: f.write('\n' + text_tm + '\n' + '答案:') except: pass
|