casper爬虫操作记录
2016-05-01 09:12
477 查看
phantom.outputEncoding = "gbk"; var fs=require("fs") //var data = fs.read("cookie.txt") //phantom.cookies = JSON.parse(data) var casper = require("casper").create({ clientScripts: ["jquery.min.js"], verbose: true, // logLevel: 'debug', safeLogs: true, viewportSize:{width: 1024, height: 768}, pageSettings: { // loadImages: false, // The WebPage instance used by Casper will // loadPlugins: false, // use these settings userAgent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36' } }) //新建一个页面 casper.start('http://www.cnblogs.com/pick/'); casper.then(function(){ this.evaluate(function() { $("a:contains('登录')").click() }); this.wait(1000, function() { this.echo("I've waited for a second."); }); }) casper.then(function(){ this.capture('qq2.png'); console.log(210) this.evaluate(function() { $("#input1").focus().val("m3m4_ck") $("#input2").focus().val("保密") $("#signin").click() }); this.wait(1000, function() { this.echo("I've waited for a second."); }); }) casper.then(function(){ this.capture('qq3.png'); }) casper.then(function(){ this.wait(2000,function(){ this.capture('qq4.png'); var cookies = JSON.stringify(phantom.cookies) fs.write("cookie.txt", cookies, 644) }) // this.fill('#Main form', { // 'text': 'm3m4_ck', // 'password': '907167' // }, false); // this.click("#signin") // // // this.wait(5000,function(){ // var cookies = JSON.stringify(phantom.cookies) // fs.write("cookie.txt", cookies, 644) // this.capture('qq2.png'); // }) }); casper.run();
相关文章推荐
- 让我们Core在一起:ASP.NET Core & .NET Core
- Spring中的AOP(七)(实际上应该是一)——AspectJ的基本使用
- Raspberry pi3 入门一
- Raspberry Pi 配置笔记二
- Asp.Net MVC 4 Web API 中的安全认证-使用OAuth
- Asp.Net MVC3 简单入门详解过滤器Filter
- 在RaspberryPi中用CasperJS对网页元素截图
- asp:DropDownList与asp:DataList的联合使用
- 【asp.net】控件
- ASP.NET MVC 网站开发总结(三) ——图片截图上传
- asp.net MVC 中 Session统一验证的方法
- ASPxGridView 导出和部分属性设置
- 1.简单实例:ASP.NET下Echarts通过Ajax从数据库中获取数据
- CS0016: 未能写入输出文件“c:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/...拒绝访问
- 未能将网站xx 配置为使用 ASP.NET 4.0。为了使此网站正确运行,您必须将它手动配置为使用 ASP.NET 4.0。
- asp.net 配置 web.config 禁用VS2013自带的Browser Link功能
- java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
- 【Raspberry Pi 3试用体验】+ngrok 内网穿透
- ireport/jasprereport studio 导出excel最后有空白行
- 【Raspberry Pi 3试用体验】+ 使用owncloud云服务