<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問(wèn)答1問(wèn)答10問(wèn)答100問(wèn)答1000問(wèn)答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問(wèn)答文章1 問(wèn)答文章501 問(wèn)答文章1001 問(wèn)答文章1501 問(wèn)答文章2001 問(wèn)答文章2501 問(wèn)答文章3001 問(wèn)答文章3501 問(wèn)答文章4001 問(wèn)答文章4501 問(wèn)答文章5001 問(wèn)答文章5501 問(wèn)答文章6001 問(wèn)答文章6501 問(wèn)答文章7001 問(wèn)答文章7501 問(wèn)答文章8001 問(wèn)答文章8501 問(wèn)答文章9001 問(wèn)答文章9501
        當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

        selenium和casperjs2種數(shù)據(jù)抓取方式(進(jìn)來(lái)的朋友請(qǐng)留言,共同探討

        來(lái)源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-09 08:32:20
        文檔

        selenium和casperjs2種數(shù)據(jù)抓取方式(進(jìn)來(lái)的朋友請(qǐng)留言,共同探討

        selenium和casperjs2種數(shù)據(jù)抓取方式(進(jìn)來(lái)的朋友請(qǐng)留言,共同探討:今天用selenium和casperjs2種對(duì)https://class.coursera.org/nlp/lecture網(wǎng)站的ppt、pdf、srt、MP4的下載地址進(jìn)行數(shù)據(jù)抓取 1、pythonselenium #!/usr/bin/python# -*- coding: utf-8 -*-from selenium import
        推薦度:
        導(dǎo)讀selenium和casperjs2種數(shù)據(jù)抓取方式(進(jìn)來(lái)的朋友請(qǐng)留言,共同探討:今天用selenium和casperjs2種對(duì)https://class.coursera.org/nlp/lecture網(wǎng)站的ppt、pdf、srt、MP4的下載地址進(jìn)行數(shù)據(jù)抓取 1、pythonselenium #!/usr/bin/python# -*- coding: utf-8 -*-from selenium import

        今天用selenium和casperjs2種對(duì)https://class.coursera.org/nlp/lecture網(wǎng)站的ppt、pdf、srt、MP4的下載地址進(jìn)行數(shù)據(jù)抓取 1、pythonselenium #!/usr/bin/python# -*- coding: utf-8 -*-from selenium import webdriverfrom bs4 import BeautifulSoupimport t

        今天用selenium和casperjs2種對(duì)https://class.coursera.org/nlp/lecture網(wǎng)站的ppt、pdf、srt、MP4的下載地址進(jìn)行數(shù)據(jù)抓取

        1、python+selenium

        #!/usr/bin/python
        # -*- coding: utf-8 -*-
        
        from selenium import webdriver
        from bs4 import BeautifulSoup
        
        import time
        import sys
        reload(sys)
        sys.setdefaultencoding('utf-8')
        
        def catchDate(s):
         """頁(yè)面數(shù)據(jù)提取"""
         soup = BeautifulSoup(s)
         z = []
         
         m = soup.findAll("ul",class_="course-item-list-div-list")
         
         for obj in m:
         try:
         print obj.previous_sibling.find('h3').get_text()
         tmp = obj.findAll('li', class_="unviewed")
         for eachli in tmp:
         titleli = eachli.find('a').get_text()
         print ' '+titleli
         allaInEachDiv = eachli.find('div', class_="course-lecture-item-resource").findAll('a')
         for eacha in allaInEachDiv:
         print ' '+eacha['href']
         except Exception, e:
         continue
         if(tmp != ""):
         z.append(tmp)
         return z
        
        starttime = time.time()
        driver = webdriver.PhantomJS(executable_path='C:\phantomjs-1.9.7-windows\phantomjs.exe')
        driver.get("https://class.coursera.org/nlp/lecture")
        html = driver.page_source
        content = catchDate(html)
        endtime = time.time()
        print endtime - starttime
        driver.quit

        2、casperjs
        var casper = require("casper").create({
        	clientScripts: ["jquery-1.7.js"], 
         stepTimeout: 120 * 1000, 
         pageSettings: { 
         loadImages: false 
         }, 
         verbose: true, 
         logLevel: "error" 
        }); 
        var numberOfLinks = 0;
        
        var fs = require('fs');
        var filename = 'content.txt';
        var fullContent = "";
        var startTime = new Date(), endTime;
         
        casper.start("https://class.coursera.org/nlp/lecture", function() {
         numberOfLinks = this.evaluate(function() {
         return __utils__.findAll('.course-item-list-div-list').length;
         });
         this.echo(numberOfLinks + " items found");
        });
        getStartTime = function(){
        	this.echo(startTime);
        	this.then(getcontent);
        };
        getcontent = function() {
         fullContent = this.evaluate(function() {
         var content = "";
         jQuery('.course-item-list-div-list').each(function() {
        	var btitle = $(this).prev().find("h3").text();
        	content += btitle + '\r\n';
        	$(this).find("li").each(function(){
        	var stitle = $(this).find("a").first().text();
        	content += stitle + '\r';
        	$(this).find("div a").each(function(){
        	content += $(this).attr("href")+'\r';
        	});
        	content += '\r\n';
        	});
        	content += '\r\n\r\n';
         });
         return content;
         });
        	this.then(writefile);
        };
        
        writefile = function() {
         this.echo('writing to ' + filename);
         fs.write(filename, fullContent, 'w');
        	this.then(getEndTime);
        };
        getEndTime = function(){
        	endTime = new Date();
        }
        casper.then(getStartTime);
        casper.then(function exitSystem() {
        	this.echo(new Date() - startTime);
         casper.exit(); 
        }); 
        
        casper.run();
        

        因?yàn)椴皇炀殻杏X(jué)寫的不太好,求大神對(duì)方法進(jìn)行指導(dǎo)!!!


        參考:

        https://gist.github.com/imjared/5201405

        http://casperjs.readthedocs.org/en/latest/modules/casper.html#evaluate

        http://blog.csdn.net/u012577500/article/details/18185399

        http://stackoverflow.com/questions/14894311/casperjs-windows-installation-how-is-it-done-the-correct-way-please

        http://blog.csdn.net/sagomilk/article/details/20800543

        聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        selenium和casperjs2種數(shù)據(jù)抓取方式(進(jìn)來(lái)的朋友請(qǐng)留言,共同探討

        selenium和casperjs2種數(shù)據(jù)抓取方式(進(jìn)來(lái)的朋友請(qǐng)留言,共同探討:今天用selenium和casperjs2種對(duì)https://class.coursera.org/nlp/lecture網(wǎng)站的ppt、pdf、srt、MP4的下載地址進(jìn)行數(shù)據(jù)抓取 1、pythonselenium #!/usr/bin/python# -*- coding: utf-8 -*-from selenium import
        推薦度:
        • 熱門焦點(diǎn)

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 一级人做人爰a全过程免费视频| 亚洲国产片在线观看| 亚洲AV综合永久无码精品天堂| 69精品免费视频| 亚洲国产成人久久综合一| 久久久精品午夜免费不卡| 国产亚洲AV夜间福利香蕉149| 免费无遮挡无遮羞在线看 | 在线观看亚洲免费| 成年在线网站免费观看无广告| 亚洲一卡二卡三卡| 久久精品亚洲一区二区| 免费国产午夜高清在线视频| 亚洲Av熟妇高潮30p| 日本zzzzwww大片免费| 亚洲免费在线视频观看| 无码国产精品久久一区免费| 亚洲国产精品成人综合色在线| 韩国欧洲一级毛片免费| 黄色一级免费网站| 亚洲小说区图片区另类春色| 久久免费国产视频| 亚洲另类自拍丝袜第五页| 亚洲免费一区二区| 久久久国产精品无码免费专区| 国产成人一区二区三区免费视频 | 亚洲精品美女在线观看| 无码国产精品一区二区免费式影视 | 免费夜色污私人影院网站| 毛茸茸bbw亚洲人| 中文字幕免费在线| 亚洲AV无码一区二区三区牲色| 亚洲精品日韩中文字幕久久久| 成人激情免费视频| 国产精品国产免费无码专区不卡 | 一本到卡二卡三卡免费高| 亚洲精品制服丝袜四区| 国产一卡二卡四卡免费| 国产亚洲欧美在线观看| 久久亚洲国产午夜精品理论片| 一本岛高清v不卡免费一三区|