""" This code is supported by the website: https://www.guanjihuan.com The newest version of this code is on the web page: https://www.guanjihuan.com/archives/18038 """ from bs4 import BeautifulSoup import re import urllib.request 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/4418").read().decode('utf-8') # directory = 'words_mp3_breProns/' # 英音 directory = 'words_mp3_ameProns/' # 美音 pygame.mixer.init() soup = BeautifulSoup(html, features='lxml') contents = re.findall('
.*?
', content, re.S)[0][3:-4] time.sleep(2.5) print(translation, '\n') time.sleep(0.5) # 调节间隔时间 pygame.mixer.music.stop()