zoukankan      html  css  js  c++  java
  • 有道词典单词本和扇贝网生词本的互动——关于扇贝生词本的分类管理功能补充

      简介:在使用扇贝网背单词时,发现它的生词本缺乏分类管理的功能——类似于有道词典的生词本的分类管理功能。在观察了有道词表的导出格式以及扇贝网生词本网页的结构后,萌生通过转换有道词表格式和爬取扇贝网生词表来实现有道和扇贝的单词本同步的想法,目的是方便生词本的分类整理和回顾。

    一、有道词表的格式转换

      首先实现有道导出词表的格式转换。有道的导出格式有三种:.txt、.xml、.bin(专有格式),其中.xml格式比较方便单词提取。

    # -*- coding: utf-8 -*-
    """
    Created on Mon Dec  7 14:17:04 2020
    
    @author: L JL
    """
    
    import  xml.dom.minidom
    #打开xml文档
    dom = xml.dom.minidom.parse('wordlist.xml')
    #得到文档元素对象
    root = dom.documentElement
    words = dom.getElementsByTagName('word')
    
    fs = open('wordlist.txt','w+')
    for word in words:
        print(word.firstChild.data)
        fs.write(word.firstChild.data)
        fs.write('
    ')
    fs.close()
    
    print('Export succeeded!')
        

    (剩下的部分会陆续补充   2020.12.07)

  • 相关阅读:
    11
    961. N-Repeated Element in Size 2N Array
    用numpy.pad()对图像进行填充及简单的图像处理
    709. To Lower Case
    929. Unique Email Addresses
    771. Jewels and Stones
    谭凯---访谈录
    如何拍照
    主题阅读法
    社会各职业工作重心和流程
  • 原文地址:https://www.cnblogs.com/liqinglong/p/14097640.html
Copyright © 2011-2022 走看看