时间仓促,先把之前的测试代码贴上

/** 方案一 模拟搜索百度(打开百度,搜索,下三页,重新搜索,点击前三条任意一条*/public static void run_one(String search_one, String search_two, int mysqlid){System.out.println(search_two);Map map = PhoneAgen.get_userAgent();//Map map = get_userAgent();String userAgent = (String) map.get("userAgent");DesiredCapabilities capabilities = null;capabilities = DesiredCapabilities.android();int phone_r_num = (int)map.get("phone_r_num");if(phone_r_num<=1){capabilities.setBrowserName("iPhone");capabilities.setPlatform(Platform.MAC);}else{capabilities.setBrowserName("android");capabilities.setPlatform(Platform.ANDROID);}//     System.out.println(capabilities.getBrowserName());
//      System.out.println(capabilities.getVersion());
//      System.out.println(capabilities.getPlatform());capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_PAGE_SETTINGS_PREFIX + "userAgent", userAgent);PhantomJSDriver dr = new PhantomJSDriver(capabilities);dr.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);try {Dimension POPULAR_DISPLAY_SIZE = new Dimension( (int)map.get("p_w"), (int) map.get("p_h"));dr.manage().window().setSize(POPULAR_DISPLAY_SIZE);System.out.println("打开百度");dr.get("http://m.baidu.com/");//((JavascriptExecutor) dr).executeScript("window.scrollBy(0, 700)"); //System.out.println(dr.getPageSource());//Thread.sleep(3000);//snapshot((TakesScreenshot)dr, "1.png");WebElement searchBox = dr.findElement(By.id("index-kw"));searchBox.sendKeys(search_one);System.out.println("在搜索框中输入文字");Thread.sleep(1000);WebElement searchButton = dr.findElement(By.className("se-bn"));//WebElement searchButton = dr.findElement(By.id("index-bn"));searchButton.submit();;System.out.println("搜索点击等待");Thread.sleep(4000);//snapshot((TakesScreenshot)dr, "2.png");System.out.println("当前地址(第一页):"+dr.getCurrentUrl());//获取高度,用来模拟鼠标滚动String page_height = ((JavascriptExecutor) dr).executeScript("return document.body.scrollHeight").toString(); int page_height_f  =  Integer.parseInt(page_height)-650;int mouse_scroll_num = mt_rand(4,5);for(int i=1;i<=mouse_scroll_num;i++){int page_height_cur = (int) (page_height_f/mouse_scroll_num);int page_height_cur_n = mt_rand(0,50);if(mt_rand(1,2)==1){page_height_cur -= page_height_cur_n;}else{page_height_cur += page_height_cur_n;}((JavascriptExecutor) dr).executeScript("window.scrollBy(0, "+page_height_cur+")");System.out.println("进入鼠标滚动(第一页)"+i+"--"+page_height_cur);Thread.sleep(mt_rand(1,3)*1000);}System.out.println("准备点击下一页");WebElement searchPage_one_next =  dr.findElement(By.className("new-nextpage-only")); //点击下一页 searchPage_one_next.click();//--------------------------------------------------------------Thread.sleep(3500);System.out.println("点击下一页后等待");//snapshot((TakesScreenshot)dr, "3.png");System.out.println("当前地址(第二页):"+dr.getCurrentUrl());String page_height2 = ((JavascriptExecutor) dr).executeScript("return document.body.scrollHeight").toString(); int page_height_f2  =  Integer.parseInt(page_height2)-650;int mouse_scroll_num2 = mt_rand(4,5);for(int i=1;i<=mouse_scroll_num2;i++) {int page_height_cur2 = (int) (page_height_f2/mouse_scroll_num2);int page_height_cur_n2 = mt_rand(0,50);if(mt_rand(1,2)==1){page_height_cur2 -= page_height_cur_n2;}else{page_height_cur2 += page_height_cur_n2;}((JavascriptExecutor) dr).executeScript("window.scrollBy(0, "+page_height_cur2+")");System.out.println("进入鼠标滚动(第二页)"+i+"--"+page_height_cur2);Thread.sleep(mt_rand(1,3)*1000);}System.out.println("准备点击下一页");WebElement searchPage_two_next =  dr.findElement(By.className("new-nextpage")); //点击下一页 searchPage_two_next.click();//--------------------------------------------------------------Thread.sleep(3500);System.out.println("点击下一页后等待");System.out.println("当前地址(第三页):"+dr.getCurrentUrl());//snapshot((TakesScreenshot)dr, "4.png");Thread.sleep(2000);//重新搜索词WebElement searchPage_text =  dr.findElement(By.id("kw"));searchPage_text.clear();searchPage_text.sendKeys(search_two);Thread.sleep(1000);WebElement searchPage_se_bn =  dr.findElement(By.className("se-bn"));searchPage_se_bn.click();//--------------------------------------------------------------Thread.sleep(4000);System.out.println("重新搜索当前地址:"+dr.getCurrentUrl());//snapshot((TakesScreenshot)dr, "5.png");//成功增加记录String sql1="Update search Set num=num+1 Where id="+mysqlid;Dbhelper.executeNonQuery(sql1); WebElement search_r1 = null;//随机点击前三个链接中的任意一个try{search_r1 =dr.findElement(By.xpath("//*[@id=\"results\"]/div[1]/div/div/div/a[1]"));int last_height = mt_rand(300,500);((JavascriptExecutor) dr).executeScript("window.scrollBy(0, "+last_height+")");System.out.println("找到广告,滚动"+last_height);}catch(Exception e){int click_num = mt_rand(2,3); search_r1 =dr.findElement(By.xpath("//*[@id=\"results\"]/div["+click_num+"]/div[1]/a"));System.out.println("没有广告,"+click_num);}search_r1.click();Thread.sleep(4000);System.out.println("打开搜索地址:"+dr.getCurrentUrl());//snapshot((TakesScreenshot)dr, "6.png");dr.quit();} catch (Exception e) {dr.quit();e.printStackTrace();}finally {dr.quit();}}
/** 方案三  搜索一次 过10-30随机秒 再次搜索*/public static void run_three(String search_one, String search_two, int mysqlid){System.out.println(search_two);Map map = PhoneAgen.get_userAgent();String userAgent = (String) map.get("userAgent");DesiredCapabilities capabilities = null;capabilities = DesiredCapabilities.android();int phone_r_num = (int)map.get("phone_r_num");if(phone_r_num<=1){capabilities.setBrowserName("iPhone");capabilities.setPlatform(Platform.MAC);}else{capabilities.setBrowserName("android");capabilities.setPlatform(Platform.ANDROID);}//        System.out.println(capabilities.getBrowserName());
//      System.out.println(capabilities.getVersion());
//      System.out.println(capabilities.getPlatform());capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_PAGE_SETTINGS_PREFIX + "userAgent", userAgent);PhantomJSDriver dr = new PhantomJSDriver(capabilities);dr.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);try {Dimension POPULAR_DISPLAY_SIZE = new Dimension( (int)map.get("p_w"), (int) map.get("p_h"));dr.manage().window().setSize(POPULAR_DISPLAY_SIZE);System.out.println("打开百度");dr.get("http://m.baidu.com/");//((JavascriptExecutor) dr).executeScript("window.scrollBy(0, 700)"); //System.out.println(dr.getPageSource());//Thread.sleep(3000);//snapshot((TakesScreenshot)dr, "1.png");WebElement searchBox = dr.findElement(By.id("index-kw"));searchBox.sendKeys(search_one);System.out.println("在搜索框中输入文字");Thread.sleep(1000);//By.xpath(xpathExpression)//*[@id="index-bn"]WebElement searchButton = dr.findElement(By.className("se-bn"));searchButton.submit();;System.out.println("搜索点击等待");Thread.sleep(4000);//snapshot((TakesScreenshot)dr, "2.png");System.out.println("当前地址(第一页):"+dr.getCurrentUrl());//获取高度,用来模拟鼠标滚动String page_height = ((JavascriptExecutor) dr).executeScript("return document.body.scrollHeight").toString(); int page_height_f  =  Integer.parseInt(page_height)-650;int mouse_scroll_num = mt_rand(4,5);for(int i=1;i<=mouse_scroll_num;i++){int page_height_cur = (int) (page_height_f/mouse_scroll_num);int page_height_cur_n = mt_rand(0,50);if(mt_rand(1,2)==1){page_height_cur -= page_height_cur_n;}else{page_height_cur += page_height_cur_n;}((JavascriptExecutor) dr).executeScript("window.scrollBy(0, "+page_height_cur+")");System.out.println("进入鼠标滚动(第一页)向下"+i+"--"+page_height_cur);Thread.sleep(mt_rand(1,3)*1000);}int mouse_scroll_num2 = mt_rand(4,5);for(int i=1;i<=mouse_scroll_num2;i++){int page_height_cur = (int) (page_height_f/mouse_scroll_num);int page_height_cur_n = mt_rand(0,50);if(mt_rand(1,2)==1){page_height_cur -= page_height_cur_n;}else{page_height_cur += page_height_cur_n;}((JavascriptExecutor) dr).executeScript("window.scrollBy(0, "+(-page_height_cur)+")");System.out.println("进入鼠标滚动(第一页)向上"+i+"--"+page_height_cur);Thread.sleep(mt_rand(1,3)*1000);}//重新搜索词WebElement searchPage_text =  dr.findElement(By.id("kw"));searchPage_text.clear();searchPage_text.sendKeys(search_two);Thread.sleep(1000);WebElement searchPage_se_bn =  dr.findElement(By.className("se-bn"));searchPage_se_bn.click();//--------------------------------------------------------------Thread.sleep(4000);System.out.println("重新搜索当前地址:"+dr.getCurrentUrl());//snapshot((TakesScreenshot)dr, "5.png");//成功增加记录String sql1="Update search Set num=num+1 Where id="+mysqlid;Dbhelper.executeNonQuery(sql1); //随机点击前三个链接中的任意一个WebElement search_r1 = null;//随机点击前三个链接中的任意一个try{search_r1 =dr.findElement(By.xpath("//*[@id=\"results\"]/div[1]/div/div/div/a[1]"));int last_height = mt_rand(300,500);((JavascriptExecutor) dr).executeScript("window.scrollBy(0, "+last_height+")");System.out.println("找到广告,滚动"+last_height);}catch(Exception e){int click_num = mt_rand(2,3); search_r1 =dr.findElement(By.xpath("//*[@id=\"results\"]/div["+click_num+"]/div[1]/a"));System.out.println("没有广告,"+click_num);}search_r1.click();Thread.sleep(4000);System.out.println("打开搜索地址:"+dr.getCurrentUrl());//snapshot((TakesScreenshot)dr, "6.png");dr.quit();} catch (Exception e) {dr.quit();e.printStackTrace();}finally {dr.quit();}}

phantomjs selenium实现刷搜索引擎,刷百度来路,刷点击,真实有效果相关推荐

  1. 邓西百度知道刷赞工具

    邓西百度知道刷赞工具(邓西百度知道刷赞工具,百度知道刷赞,谁有百度知道刷赞软件,百度知道赞怎么刷,百度知道刷赞工具,百度刷赞软件,百度点赞机)是一款专门百度知道营销的软件,这个主要是在抢占热门问答流量 ...

  2. 用python来个百度关键词刷排名脚本

    目的:写个脚本来提升百度排名 我一个seo届前辈的朋友找我,他说,seo事无巨细,自己主观方面能做的几乎都能做了,提升百度等搜索引擎中的排名往往效果不佳或者起效周期慢.能不能人为去干预下呢? 获得排名 ...

  3. 刷百度下拉那个词与百度快排点击原理是什么?做快排网站降权怎么办?

    前言:这是白杨SEO公众号原创第344篇.为什么写这个?因为之前群里有人问百度下拉词原理是什么?还有一些朋友反映说做快排网站严重降权怎么办?今天就来分享一下. 声明:不管是下拉还是快排,白杨SEO均不 ...

  4. 搜索引擎下拉食云速捷详细_两招刷搜索引擎下拉框的方法分享

    百度里面大家搜索词语的时候会弹出来一些下拉框,这下拉框有些人会特意的使用,比如说会出现他的QQ号,这样你会赢到大量的流量,所以说我们今天就来分享一下如何去刷搜索引擎的下拉框. 1:大量ip 根据百度的 ...

  5. 金立e3t刷android4.4,金立E3T 刷机包 百度云完美版

    [出品]:812601591 [特性] 1. 安全稳定:基于百度云最新版rom精简优化,稳定运行! 2. 省电耐用:添加独有省电逻辑,待机时长优于官方! 3. 深度精简:剔除大量冗余的官方应用及多余插 ...

  6. 金立e3t刷android4.4,金立E3T刷机包 基于百度云官方ROM 深度精简 超强权限 省电耐用 安全稳定...

    [特性] 1. 安全稳定:基于百度云最新版rom精简优化,稳定运行! 2. 省电耐用:添加独有省电逻辑,待机时长优于官方! 3. 深度精简:剔除大量冗余的官方应用及多余插件 4. 超强权限:增加完整r ...

  7. 百度云ROM刷机工具(百度刷机精灵) v2.0.23 官方正式版

    百度云ROM刷机工具(百度刷机精灵) v2.0.23 官方正式版 软件大小:19.6MB 软件语言:简体中文 软件性质:常用软件 软件授权:官方版 更新时间:2014-03-24 应用平台:Win8/ ...

  8. 互点流量,互刷排名,刷下拉刷联想-胖虎图图-互动点击系统

    软件绿色免安装,打开即可使用. 软件大小:1.4MB 支持平台:win2000/win2003/winxp/win7/win8 下载地址:http://www.phtoto.com/download/ ...

  9. [Python爬虫] 在Windows下安装PIP+Phantomjs+Selenium

    最近准备深入学习Python相关的爬虫知识了,如果说在使用Python爬取相对正规的网页使用"urllib2 + BeautifulSoup + 正则表达式"就能搞定的话:那么动态 ...

  10. android go 刷机教程,安卓用的久了,如何刷机?安卓手机线刷教程

    安卓手机线刷教程进入下载刷机精灵 5.0.0.500 官方版 大小:25.3 MB 日期:2019/8/29 16:35:52 环境:WinXP, Win7, Win8, Win10, WinAll ...

最新文章

  1. 香港大学提出OneNet:一阶段端到端目标检测网络,无需NMS!无需二分匹配!
  2. Reactjs 踏坑指南3:一些例子(未完成)
  3. POJ2391(最大流Isap+Floyd+二分)
  4. Java学习笔记-7.Java IO流
  5. Javascript与服务器同步时间
  6. oracle dbstart,dbstart: 未找到命令
  7. 振奋!中国正式进入5G元年;华为5G俄罗斯签下大单;王坚进入工程院院士第二轮评审...
  8. Linux上的redis安装和后台启动
  9. MySQL.. ERROR! The server quit without updating PID file问题解决
  10. WPS office 下载
  11. 最新MySql安装教学,非常详细
  12. 什么是bypass(转载)
  13. 阿里快递扩张之路:集齐“四通一达”后持续增持,再花百亿图啥?
  14. 解决remote: You are not allowed to upload code.fatal: unable to access.The requested URL error:403
  15. Ubuntu 18.04 字体显示异常
  16. (几何方面:正六边形面积)编写一个程序,提示用户输入正六边形的边长并显示它的面积。
  17. 谷粒商城基础篇——Day01
  18. 【云服务器搭建游戏私服】全流程
  19. linux查看vm_type,【心得,备忘录】查看vmlinux的符号信息
  20. SVHN门牌号数据集 再生成印刷体数据集

热门文章

  1. CancelledError: [_Derived_]RecvAsync is cancelled.
  2. Python项目分析:预测双色球福利彩票中奖号码(随便玩玩,不要当真)
  3. 淘宝搜索上传图片获得上传sid
  4. 添加Nginx ALG模块支持FTP协议ALG
  5. 2021虫虫百度域名URL批量采集工具【自动去重】
  6. oracle创建一个永久性表空间,oracle创建表空间
  7. 链接mysql 504_总结403到504的常用问题
  8. 智能车图像处理(三)元素判断
  9. Aho Corasick自动机结合DoubleArrayTrie极速多模式匹配
  10. 查看签名apk调试日志工具