亚洲免费av电影一区二区三区,日韩爱爱视频,51精品视频一区二区三区,91视频爱爱,日韩欧美在线播放视频,中文字幕少妇AV,亚洲电影中文字幕,久久久久亚洲av成人网址,久久综合视频网站,国产在线不卡免费播放

        ?

        基于網(wǎng)絡(luò)爬蟲(chóng)的單詞翻譯器設(shè)計(jì)與研究

        2021-09-13 08:52:16周游宇孫洪波梅良才
        科技資訊 2021年16期
        關(guān)鍵詞:網(wǎng)絡(luò)爬蟲(chóng)

        周游宇 孫洪波 梅良才

        摘? 要:該文基于機(jī)器學(xué)習(xí)中的網(wǎng)絡(luò)爬蟲(chóng)技術(shù)提出了一種單詞翻譯器的設(shè)計(jì)與研究流程。首先,該文對(duì)Iciba網(wǎng)站進(jìn)行爬蟲(chóng),經(jīng)過(guò)前期url分析,編寫(xiě)定向頁(yè)面requests爬蟲(chóng),得到單詞釋義和例句。其次,通過(guò)一個(gè)查詢單詞的通用程序框架,編寫(xiě)requests定向爬蟲(chóng),實(shí)時(shí)獲得最新的詞語(yǔ)解釋和例句。最后,該文設(shè)計(jì)了一個(gè)GUI窗體界面,用于展示相關(guān)結(jié)果,具有較好的實(shí)用性和有效性。該文提出的研究方法是機(jī)器學(xué)習(xí)相關(guān)研究領(lǐng)域的一個(gè)擴(kuò)充,且該研究結(jié)果給教育相關(guān)領(lǐng)域提供了一個(gè)有效的應(yīng)用產(chǎn)品。

        關(guān)鍵詞:requests框架? 網(wǎng)絡(luò)爬蟲(chóng)? GUI界面編程? Python

        中圖分類號(hào):TP391? ? ? ? ? ? ? ? ? ? ? ?文獻(xiàn)標(biāo)識(shí)碼:A文章編號(hào):1672-3791(2021)06(a)-0004-03

        Design and Research of Word Translator Based on Web Crawler

        ZHOU Youyu? SUN Hongbo? MEI Liangcai*

        (Beijing Institute of Technology, Zhuhai, Zhuhai, Guangdong Province, 519088? China)

        Absrtact: This paper presents the design and research flow of a word translator based on the web crawler technology in machine learning. Firstly, this paper crawled Iciba website, compiled directional page requests crawler through early url analysis, compiled the directed page requests crawler, got the word definition and example sentences. Secondly, through a general program framework for querying words, write requests directional crawler to obtain the latest word interpretation and example sentences in real time. Finally, a GUI form interface is designed to show the relevant results, which has good practicability and effectiveness. The research method proposed in this paper is an extension of the research field related to machine learning, and the research results provide an effective application product for the field related to education.

        Key Words: Requests framework; Web crawler; GUI interface programming; Python

        網(wǎng)絡(luò)爬蟲(chóng)是從互聯(lián)網(wǎng)搜集數(shù)據(jù)的一種工具,眾多學(xué)者利用網(wǎng)絡(luò)爬蟲(chóng)獲取研究數(shù)據(jù)[1]。機(jī)器學(xué)習(xí)是一種從現(xiàn)有數(shù)據(jù)中找到數(shù)據(jù)特征之間變化規(guī)律的一門(mén)科學(xué),學(xué)者們?cè)诜g器設(shè)計(jì)、數(shù)據(jù)預(yù)測(cè)等多種交叉領(lǐng)域都用到了機(jī)器學(xué)習(xí)方法[2-4]。另外,市場(chǎng)上大多數(shù)查詢單詞App的桌面版功能都不夠方便快捷,基于此現(xiàn)狀,該文主要基于以下任務(wù)來(lái)設(shè)計(jì)單詞查詢App。

        (1)對(duì)于網(wǎng)頁(yè)架構(gòu)的前期url分析,找到相應(yīng)的單詞釋義和例句。

        (2)對(duì)于html框架中的具體label中的內(nèi)容進(jìn)行編程設(shè)計(jì)爬取。

        (3)設(shè)計(jì)GUI界面進(jìn)行單詞釋義和例句的展示。

        1? 包的安裝與描述

        因?yàn)橐狦UI界面編程和網(wǎng)絡(luò)爬蟲(chóng),因此需要下列包。

        from PyQt5 import QtCore, QtGui, QtWidgets

        from bs4 import BeautifulSoup

        from PyQt5.QtCore import QRect

        import requests

        from PyQt5.QtWidgets.

        import QApplication,QWidget

        import sys

        import trans

        2? 爬蟲(chóng)解決過(guò)程

        Iciba的域名為http://www.iciba.com/,在域名后加word?w=,再加入所要搜索的單詞,如book。顯示出如下網(wǎng)址:http://www.iciba.com/word?w=book,即可完成搜索,url見(jiàn)圖1。

        由圖1可知,單詞釋義都在class=Mean_part_1RA2V的ul標(biāo)簽下,每一個(gè)li標(biāo)簽里帶有一行釋義;li標(biāo)簽下的i標(biāo)簽帶有此行釋義的詞性,span標(biāo)簽為漢語(yǔ)解釋。同理,例句在 class = NormalSentence_sentence_3q5Wk的div標(biāo)簽下。三個(gè)p標(biāo)簽分別為英語(yǔ)例句、漢語(yǔ)翻譯、出處。

        至此,筆者寫(xiě)出爬蟲(chóng)的主要框架具體如下所示。

        r = requests.get(url)

        try:

        soup = BeautifulSoup(r.text,'html.parser')

        meaning = soup.find('ul',class_='Mean_part_1RA2V').children

        for li in meaning:

        text += li.i.string

        text+=' '

        for span in li.div.children:

        text+=span.text

        text+=' '

        text+='\n'

        text+='\n例句:\n'

        for div in soup.findAll('div',class_='NormalSentence_sentence_3q5Wk')[:9]:

        ps = div.children

        i=0

        for p in ps:

        if i == 2:

        break

        text += p.text

        text+='\n'

        i+=1

        text+='\n'

        self.label.setText(text)

        except:

        self.label.setText('搜索失敗')

        利用try-except語(yǔ)句用一些亂七八糟搜索的過(guò)濾。

        3? GUI界面解決過(guò)程

        GUI界面能很直觀地展示搜集結(jié)果,是展示網(wǎng)絡(luò)爬蟲(chóng)數(shù)據(jù)的好工具[5-6]。利用類的定義和使用的方法,筆者根據(jù)官網(wǎng)例子寫(xiě)出的GUI如下所示。

        from PyQt5 import QtCore, QtGui, QtWidgets

        from bs4 import BeautifulSoup

        from PyQt5.QtCore import QRect

        import requests

        class Ui_Form(object):

        def setupUi(self, Form):

        Form.setObjectName("Form")

        Form.resize(412, 800)

        self.Buttons = QtWidgets.QPushButton(Form)

        self.Buttons.setGeometry(QtCore.QRect(300, 10, 93, 28))

        self.Buttons.setObjectName("Buttons")

        self.lineEdit = QtWidgets.QLineEdit(Form)

        self.lineEdit.setGeometry(QtCore.QRect(10, 10, 271, 31))

        self.lineEdit.setObjectName("lineEdit")

        self.label = QtWidgets.QLabel(Form)

        self.label.setGeometry(QtCore.QRect(10, 50, 381, 711))

        self.label.setText("")

        self.label.setObjectName("label")

        self.label.setGeometry(QRect(10, 50, 381, 711))

        self.label.setWordWrap(True)

        self.label.setAlignment(QtCore.Qt.AlignTop)

        self.Buttons.clicked.connect(self.sOnClicked)

        self.retranslateUi(Form)

        QtCore.QMetaObject.connectSlotsByName(Form)

        def sOnClicked(self):

        text = '釋義:\n'

        url_root = 'http://www.iciba.com/word?w='

        url = url_root+self.lineEdit.text()

        r = requests.get(url)

        try:

        soup = BeautifulSoup(r.text,'html.parser')

        meaning = soup.find('ul',class_='Mean_part_1RA2V').children

        for li in meaning:

        text += li.i.string

        text+=' '

        for span in li.div.children:

        text+=span.text

        text+=' '

        text+='\n'

        text+='\n例句:\n'

        for div in soup.findAll('div',class_='NormalSentence_sentence_3q5Wk')[:9]:

        ps = div.children

        i=0

        for p in ps:

        if i == 2:

        break

        text += p.text

        text+='\n'

        i+=1

        text+='\n'

        self.label.setText(text)

        except:

        self.label.setText('搜索失敗')

        def retranslateUi(self, Form):

        _translate = QtCore.QCoreApplication.translate

        Form.setWindowTitle(_translate("Form", "Form"))

        self.Buttons.setText(_translate("Form", "搜詞"))

        4? 總結(jié)與評(píng)價(jià)

        (1)創(chuàng)新點(diǎn)。運(yùn)用的GUI界面編程,程序有了界面可以和用戶互動(dòng);根據(jù)網(wǎng)絡(luò)爬蟲(chóng)可快速制作出編譯器,無(wú)需自己的詞典庫(kù);界面自適應(yīng),長(zhǎng)出界面的詞句會(huì)自動(dòng)換行;詞性、釋義、例句,一應(yīng)俱全。

        (2)不足和改進(jìn)。查詢需要聯(lián)網(wǎng),沒(méi)有自己的數(shù)據(jù)備份。

        該款A(yù)pp可以用于日常英語(yǔ)學(xué)習(xí),隨時(shí)查詢,沒(méi)有多余功能,程序小巧,查詢到的釋義例句齊全。

        參考文獻(xiàn)

        [1] 朱策,徐宏,林新,等.基于網(wǎng)絡(luò)爬蟲(chóng)的能源政策監(jiān)測(cè)[J].科技創(chuàng)新導(dǎo)報(bào),2019,16(35):141-142.

        [2] 楊浩波.神經(jīng)機(jī)器翻譯關(guān)鍵技術(shù)研究與應(yīng)用[D].成都:電子科技大學(xué),2020.

        [3] 梁娟.英語(yǔ)翻譯器語(yǔ)音識(shí)別系統(tǒng)的設(shè)計(jì)及功能實(shí)現(xiàn)[J].微型電腦應(yīng)用,2018,34(12):46-48.

        [4] 季春元,熊澤金,侯艷芳,等.基于人機(jī)交互的網(wǎng)絡(luò)化智能翻譯系統(tǒng)設(shè)計(jì)[J].自動(dòng)化與儀器儀表,2019(8):25-28.

        [5] 劉江,劉國(guó)璽,張雁,等.基于多線程和翻譯的網(wǎng)絡(luò)爬蟲(chóng)鳥(niǎo)類音頻數(shù)據(jù)采集系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn)[J].現(xiàn)代計(jì)算機(jī),2018(30):85-88,92.

        [6] 明日科技.Python從入門(mén)到精通[M].北京:清華大學(xué)出版社,2018.

        猜你喜歡
        網(wǎng)絡(luò)爬蟲(chóng)
        煉鐵廠鐵量網(wǎng)頁(yè)數(shù)據(jù)獲取系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)
        基于社會(huì)網(wǎng)絡(luò)分析的權(quán)威網(wǎng)頁(yè)挖掘研究
        主題搜索引擎中網(wǎng)絡(luò)爬蟲(chóng)的實(shí)現(xiàn)研究
        淺析如何應(yīng)對(duì)網(wǎng)絡(luò)爬蟲(chóng)流量
        網(wǎng)絡(luò)爬蟲(chóng)針對(duì)“反爬”網(wǎng)站的爬取策略研究
        久久久噜噜噜久久熟女| 成人三级在线| 久久一区二区三区不卡| 亚洲精品一区二区三区四区| 亚洲欧洲日产国码av系列天堂| 国产成熟人妻换╳╳╳╳| 国产91网址| 精品少妇白浆一二三区| 国产成年人毛片在线99| 97精品超碰一区二区三区| 青草福利在线| 亚洲中文字幕在线第二页| 成人麻豆视频免费观看| 肉体裸交137日本大胆摄影| 国产AV无码专区久久精品网站| 精品一区二区三区中文字幕在线| 99久久国内精品成人免费| 国色天香精品一卡2卡3卡4| 91精品福利一区二区| 久久一二三四区中文字幕| 色婷婷精品久久二区二区蜜臀av| 欧美a级毛欧美1级a大片免费播放| 精品手机在线视频| 国产日韩乱码精品一区二区| 欧美精品无码一区二区三区| 国产精品久久久久影院嫩草| 色综合久久久久综合999| 国产一区二区视频在线看| 久久久久88色偷偷| 少妇太爽了在线观看| 一区二区三区国产精品| 亚洲最大中文字幕在线| 在线综合亚洲欧洲综合网站| 国产精品国产三级国产专播| 亚洲国产91精品一区二区| 亚洲精品色午夜无码专区日韩 | 久久久精品国产免大香伊| 成人一区二区免费视频| 亚洲天堂无码AV一二三四区| 亚洲黄色一级在线观看| 亚洲老妈激情一区二区三区|