diff --git a/API_Reference/API_Reference.py b/API_Reference/API_Reference.py index d3862d2..10b432c 100644 --- a/API_Reference/API_Reference.py +++ b/API_Reference/API_Reference.py @@ -272,4 +272,6 @@ content = guan.pdf_to_text(pdf_path) guan.pdf_to_audio(pdf_path, rate=125, voice=1, read=1, save=0, print_text=0) -guan.play_academic_words(bre_or_ame='ame', random_on=0, show_translation=1, show_link=1, translation_time=2, rest_time=1) \ No newline at end of file +guan.play_academic_words(bre_or_ame='ame', random_on=0, show_translation=1, show_link=1, translation_time=2, rest_time=1) + +guan.play_element_words(random_on=0, show_translation=1, show_link=1, translation_time=2, rest_time=1) \ No newline at end of file diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index 55f7d1c..9a85b7b 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.0.77 +version = 0.0.78 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index 2d36fd0..b5d2883 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -1825,4 +1825,58 @@ def play_academic_words(bre_or_ame='ame', random_on=0, show_translation=1, show_ print(translation) time.sleep(rest_time) pygame.mixer.music.stop() + print() + +def play_element_words(random_on=0, show_translation=1, show_link=1, translation_time=2, rest_time=1): + from bs4 import BeautifulSoup + import re + import urllib.request + import requests + import os + import pygame + import time + import ssl + import random + ssl._create_default_https_context = ssl._create_unverified_context + html = urllib.request.urlopen("https://www.guanjihuan.com/archives/10897").read().decode('utf-8') + directory = 'prons/' + exist_directory = os.path.exists(directory) + html_file = urllib.request.urlopen("https://file.guanjihuan.com/words/periodic_table_of_elements/"+directory).read().decode('utf-8') + if exist_directory == 0: + os.makedirs(directory) + soup = BeautifulSoup(html, features='lxml') + contents = re.findall('
.*?
', content, re.S)[0][3:-4] + if show_translation==1: + time.sleep(translation_time) + print(translation) + time.sleep(rest_time) + pygame.mixer.music.stop() print() \ No newline at end of file