新手小白求助各位大佬解决爬虫问题

本人是自学加线上培训的一个小白,目前刚学习爬虫半个月时间,想向各位大佬求助在学习过程中遇到的问题
问题如下:
现在想要复制一个单词检测网站,并做一定的改良,在代码上出现了一些错误。麻烦各位大佬帮忙看看是哪里出了问题,非常感谢了,

链接:
https://www.shanbay.com/

下面是代码:

import requests , json
url = ‘https://www.shanbay.com/api/v1/vocabtest/category/?’
headers = {‘user-agent’:‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36’}
res = requests.get(url,headers=headers)
js_res = res.json()
choice = int(input(‘你想要选择哪个出题范围\n:0是gmat,\n1是考研,\n2是高考,\n3是四级,\n4是六级,\n5是英专,\n6是托福,\n7是GRE,\n8是雅思,\n9是任意\n请输入要考科目的数字:’))
ciku = js_res[‘data’][choice-1][0]
danci = requests.get(‘https://www.shanbay.com/api/v1/vocabtest/vocabularies/?category=’+ciku+’&_=1584275910513’)
words = danci.json()

list_danci = []
k_danci = []
d_danci = []

n = 0
print(‘如果这个单词你认识请输入y,如果不认识请输入n。’)
for i in words[‘data’]:

n=n+1

print('第'+str(n)+'个\n'+i['content'])
answer = input('认识请按y,不认识请按n:\n')

if answer == 'y':
    list_danci.append(i)
    k_danci.append(i['content'])
else:
    d_danci.append(i)

wrong_danci = []
right_num = 0
for y in k_danci:
print(’\n\n’+‘A:’+y[‘definition_choices’][0][‘definition’])
print(‘B:’+y[‘definition_choices’][1][‘definition’])
print(‘C:’+y[‘definition_choices’][2][‘definition’])
print(‘D:’+y[‘definition_choices’][3][‘definition’])
xuanze = input(‘请选择单词"’+y[‘content’]+’"的正确翻译(输入字母即可):’)
dic = {‘A’:y[‘definition_choices’][0][‘rank’],‘B’:y[‘definition_choices’][1][‘rank’],‘C’:y[‘definition_choices’][2][‘rank’],‘D’:y[‘definition_choices’][3][‘rank’]}
if dic[xuanze] == y[‘rank’]:
right_num += 1
else:
wrong_danci.append(y)

save = input(‘是否打印错题集\nY/N’)
if save == ‘Y’:
f= open(‘错题集.txt’,‘a+’)
print(‘你记错的单词有:\n’)
f.write(‘你记错的单词有:\n’)
m=0
for z in wrong_danci:
m = m+1
print(z[‘content’])
f.write(str(m)+z[‘content’]+’\n’)
print(‘你不认识的单词有:’)
f.wirte(‘你不认识的单词有:\n’)

s=0
for x in d_danci:
    s=s+1
    print(i['content'])
    f.wirte(str(s)+'.'+i['content']+'\n')
print('记得经常看看错题,错题已经保存在电脑上')

else:
print(‘继续加油,下次见’)

麻烦各位大佬帮忙看下哪里需要改进。再次感谢大佬

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值