我对编程很陌生。学习python以加快我与Anki的语言学习。我想为Anki创建网页抓取脚本,以便更快地创建卡片。这是我的代码:(这不是最终产品,我想学习如何发送到csv文件,这样我就可以导入到Anki。)
from bs4 import BeautifulSoup
import requests
#get data from user
input("Type word ")
#get page
page = requests.get("https://fr.wiktionary.org/wiki/", params=word)
#make bs4 object
soup = BeautifulSoup(page.content, 'html.parser')
#find data from soup
IPA=soup.find(class_='API')
partofspeech=soup.find(class_='ligne-de-forme')
#open file
f=open("french.txt", "a")
#print text
print (IPA.text)
print (partofspeech.text)
#write to file
f.write(IPA.text)
f.write(partofspeech.text)
#close file
f.close()
它只返回Wikitionnaire的“每日词汇”,而不返回用户的输入。有什么想法吗
您可以遵循以下方法
(1)读法语,在纸上记下你想学的单词或句子
(2)将这些单词/句子写在{text,json,markdown,}文件中
(3)使用具有I/O处理的Python阅读这些世界
(4)使用运行web服务器的anki-connect与您的Anki帐户进行交互
(5)编写一个Python脚本,将输入的单词发布到HTTP,并在deepl.com上获取答案
(6)结合这些工具,在一个命令中向Anki添加一个学习会话
(7)快乐学习
一些代码
Anki connect
使用scrapy
Shell脚本,结束所有
相关问题 更多 >
编程相关推荐