How to climb the phonetic alphabet with Python
This article mainly explains "how to use Python to climb the phonetic alphabet". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to climb the phonetic alphabet with Python".
#-*-coding: UTF-8-*-import requestsimport timefrom bs4 import BeautifulSoupf = open ('. / words.txt') fw = open ('. / result.txt','a') line = f.readline () index = 0while line: index = index+1 url = "https://www.oxfordlearnersdictionaries.com/definition/english/" + line.strip () print (str (index) +": "+ url) wbdata = requests.get (url,headers= {'User-Agent':' Mozilla/5.0 (Macintosh) Intel Mac OS X 10 / 12 / 1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36'}) .text soup = BeautifulSoup (wbdata) 'html.parser') news_titles = soup.select ("span.pron-g > span.phon") # print (news_titles) result =' 'for n in news_titles: title = n.get_text () if' NAmE' in title: result + ='['+ title.replace ('NAmE',''). Replace (' / /' Print (result) fw.write ((result + "\ n") .encode ("utf-8") line = f.readline () time.sleep (0.1) fw.close () f.close () Thank you for your reading The above is the content of "how to use Python to climb phonetic symbols". After the study of this article, I believe you have a deeper understanding of how to use Python to climb phonetic symbols, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!