做爰高潮a片〈毛片〉,尤物av天堂一区二区在线观看,一本久久A久久精品VR综合,添女人荫蒂全部过程av

最新文章專題視頻專題問答1問答10問答100問答1000問答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
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識百科 - 正文

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

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

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

selenium和casperjs2種數(shù)據(jù)抓取方式(進(jìn)來的朋友請留言,共同探討:今天用selenium和casperjs2種對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)來的朋友請留言,共同探討:今天用selenium和casperjs2種對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種對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種對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):
 """頁面數(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寫的不太好,求大神對方法進(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)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

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

selenium和casperjs2種數(shù)據(jù)抓取方式(進(jìn)來的朋友請留言,共同探討:今天用selenium和casperjs2種對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
主站蜘蛛池模板: 丰城市| 沙河市| 监利县| 正蓝旗| 衡阳市| 泽州县| 兴隆县| 华坪县| 平塘县| 丘北县| 泾源县| 新宾| 湖北省| 天门市| 长顺县| 江达县| 祁连县| 焉耆| 闻喜县| 屯留县| 丰宁| 宁蒗| 呼伦贝尔市| 石泉县| 兴义市| 句容市| 宁国市| 阿瓦提县| 托克逊县| 桂平市| 咸丰县| 南平市| 石屏县| 宿松县| 新巴尔虎左旗| 新丰县| 普兰店市| 砚山县| 交口县| 西乌珠穆沁旗| 德惠市|