phantomjs 开发爬虫框架
函数
- page.childframescount
- page.childframesname
- page.close
- page.currentframename
- page.deletelater
- page.destroyed
- page.evaluate
- page.initialized
- page.injectjs
- page.javascriptalertsent
- page.javascriptconsolemessagesent
- page.loadfinished
- page.loadstarted
- page.openurl
- page.release
- page.render
- page.resourceerror
- page.resourcereceived
- page.resourcerequested
- page.uploadfile
- page.sendevent
- page.setcontent
- page.switchtochildframe
- page.switchtomainframe
- page.switchtoparentframe
- page.addcookie
- page.deletecookie
- page.clearcookies
回调处理程序/
列表中的所有页面的事件:
- oninitialized
- onloadstarted
- onloadfinished
- onurlchanged
- onnavigationrequested
- onrepaintrequested
- onresourcerequested
- onresourcereceived
- onresourceerror
- onresourcetimeout
- onalert
- onconsolemessage
- onclosing
| page.onInitialized = function() { | |
| console.log("page.onInitialized"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| page.onLoadStarted = function() { | |
| console.log("page.onLoadStarted"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| page.onLoadFinished = function() { | |
| console.log("page.onLoadFinished"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| page.onUrlChanged = function() { | |
| console.log("page.onUrlChanged"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| page.onNavigationRequested = function() { | |
| console.log("page.onNavigationRequested"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| page.onRepaintRequested = function() { | |
| console.log("page.onRepaintRequested"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| if (logResources === true) { | |
| page.onResourceRequested = function() { | |
| console.log("page.onResourceRequested"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| page.onResourceReceived = function() { | |
| console.log("page.onResourceReceived"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| } | |
| page.onClosing = function() { | |
| console.log("page.onClosing"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| // window.console.log(msg); | |
| page.onConsoleMessage = function() { | |
| console.log("page.onConsoleMessage"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| // window.alert(msg); | |
| page.onAlert = function() { | |
| console.log("page.onAlert"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| // var confirmed = window.confirm(msg); | |
| page.onConfirm = function() { | |
| console.log("page.onConfirm"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| // var user_value = window.prompt(msg, default_value); | |
| page.onPrompt = function() { | |
| console.log("page.onPrompt"); | |
| printArgs.apply(this, arguments); | |
| }; | |
| //////////////////////////////////////////////////////////////////////////////// | |
| setTimeout(function() { | |
| console.log(""); | |
| console.log("### STEP 1: Load '" + step1url + "'"); | |
| page.open(step1url); | |
| }, 0); | |
| setTimeout(function() { | |
| console.log(""); | |
| console.log("### STEP 2: Load '" + step2url + "' (load same URL plus FRAGMENT)"); | |
| page.open(step2url); | |
| }, 5000); | |
| setTimeout(function() { | |
| console.log(""); | |
| console.log("### STEP 3: Click on page internal link (aka FRAGMENT)"); | |
| page.evaluate(function() { | |
| var ev = document.createEvent("MouseEvents"); | |
| ev.initEvent("click", true, true); | |
| document.querySelector("a[href='#Event_object']").dispatchEvent(ev); | |
| }); | |
| }, 10000); | |
| setTimeout(function() { | |
| console.log(""); | |
| console.log("### STEP 4: Click on page external link"); | |
| page.evaluate(function() { | |
| var ev = document.createEvent("MouseEvents"); | |
| ev.initEvent("click", true, true); | |
| document.querySelector("a[title='JavaScript']").dispatchEvent(ev); | |
| }); | |
| }, 15000); | |
| setTimeout(function() { | |
| console.log(""); | |
| console.log("### STEP 5: Close page and shutdown (with a delay)"); | |
| page.close(); | |
| setTimeout(function(){ | |
| phantom.exit(); | |
| }, 100); | |
| }, 20000); |
网络监控
var page = require('webpage').create();
page.onResourceRequested = function(request) {
console.log('Request ' + JSON.stringify(request, undefined, ));
};
page.onResourceReceived = function(response) {
console.log('Receive ' + JSON.stringify(response, undefined, ));
};
page.open(url);
phantomjs 开发爬虫框架的更多相关文章
- 《Python3网络爬虫开发实战》PDF+源代码+《精通Python爬虫框架Scrapy》中英文PDF源代码
下载:https://pan.baidu.com/s/1oejHek3Vmu0ZYvp4w9ZLsw <Python 3网络爬虫开发实战>中文PDF+源代码 下载:https://pan. ...
- C# 爬虫框架实现 流程_各个类开发
目录链接:C# 爬虫框架实现 概述 对比通用爬虫结构,我将自己写的爬虫分为五个类实现: Spider主类:负责设置爬虫的各项属性 Scheduler类:负责提供URL到下载类,接收URL并做去重 Do ...
- 学习用java基于webMagic+selenium+phantomjs实现爬虫Demo爬取淘宝搜索页面
由于业务需要,老大要我研究一下爬虫. 团队的技术栈以java为主,并且我的主语言是Java,研究时间不到一周.基于以上原因固放弃python,选择java为语言来进行开发.等之后有时间再尝试pytho ...
- 分布式爬虫框架XXL-CRAWLER
<分布式爬虫框架XXL-CRAWLER> 一.简介 1.1 概述 XXL-CRAWLER 是一个分布式爬虫框架.一行代码开发一个分布式爬虫,拥有"多线程.异步.IP动态代理.分布 ...
- php 爬虫框架
发现两款不错的爬虫框架,极力推荐下: phpspider 一款优秀的PHP开发蜘蛛爬虫 官方下载地址:https://github.com/owner888/phpspider 官方开发手册:http ...
- 洗礼灵魂,修炼python(72)--爬虫篇—爬虫框架:Scrapy
题外话: 前面学了那么多,相信你已经对python很了解了,对爬虫也很有见解了,然后本来的计划是这样的:(请忽略编号和日期,这个是不定数,我在更博会随时改的) 上面截图的是我的草稿 然后当我开始写博文 ...
- Scrapy爬虫框架教程(四)-- 抓取AJAX异步加载网页
欢迎关注博主主页,学习python视频资源,还有大量免费python经典文章 sklearn实战-乳腺癌细胞数据挖掘 https://study.163.com/course/introduction ...
- 教你分分钟学会用python爬虫框架Scrapy爬取心目中的女神
本博文将带领你从入门到精通爬虫框架Scrapy,最终具备爬取任何网页的数据的能力.本文以校花网为例进行爬取,校花网:http://www.xiaohuar.com/,让你体验爬取校花的成就感. Scr ...
- [开源 .NET 跨平台 数据采集 爬虫框架: DotnetSpider] [一] 初衷与架构设计
[DotnetSpider 系列目录] 一.初衷与架构设计 二.基本使用 三.配置式爬虫 四.JSON数据解析与配置系统 为什么要造轮子 同学们可以去各大招聘网站查看一下爬虫工程师的要求,大多是招JA ...
随机推荐
- 【ASP.NET Core】如何隐藏响应头中的 “Kestrel”
全宇宙人民都知道,ASP.NET Core 应用是不依赖服务器组件的,因此它可以独立运行,一般是使用支持跨平台的 Kestrel 服务器(当然,在 Windows 上还可以考虑用 HttpSys,但要 ...
- 移动端H5地图离线瓦片方案
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 移动端的网速和流量耗费是移动开发必须考虑的两个点.常规的瓦片展 ...
- 火狐浏览器中如何删除保存的cookie
大致分为三步即可: 打开浏览器并查看图示,按照图示操作即可完成:
- 如何使用maven搭建web项目
博客园注册了有二十多天了,还没有写过博客,今天就发一篇,也便于后面查找笔记. 我个人已经做了几年的java web开发了,由于所在的公司是业务型公司,用的都是一些老旧的稳定技术,很少接触到稍微新点的内 ...
- Python读取配置文件,并连接数据库SQL Server
用配置文件保存固定的连接数据,改的话比较方便. 1.新建一个配置文件:SQlconfig.config,以数据库为例. 内容如下,当然也可以添加多个 [Database1] database=db_t ...
- C语言第二次博客作业—分支结构
一.PTA实验作业 题目1:计算分段函数 1.实验代码 double x,y; scanf("%lf",&x); if(x>=0){ y=sqrt(x); print ...
- bug终结者 团队作业第六、七周
bug终结者 团队作业第六.七周 作业要求:团队作业第六.七周 博客编辑:20162322 朱娅霖 一.修改<需求规格说明书> <需求规格说明书>2.0版(即初稿) <需 ...
- Alpha冲刺集合
Alpha冲刺集合 Day1 http://www.cnblogs.com/bugLoser/p/7901016.html Day2 http://www.cnblogs.com/bugLoser/p ...
- fs检测文件夹状态
var http = require("http"); var fs = require("fs"); var server = http.createServ ...
- Swift -欢迎界面1页, 延长启动图片的显示时间(LaunchImage)
转自:http://www.hangge.com/blog/cache/detail_1238.html http://www.hangge.com/blog/cache/detail_672.htm ...