4.13从明朝建立到清军入关强化练习-人教统编版高中历史必修中外历史纲要(上).pdf
2022-01-13 09:04:56 11KB 资料
需要的添加的jar包及工具:我这里使用maven来构建项目,添加依赖如下:   org.seleniumhq.selenium   selenium-java   3.2.0    PhantomJs工具到官网去下载:http://phantomjs.org/download.html 尽量都使用最新版本,不然会出现版本兼容的情况。 这里有一个已经写好的获取PhantomJSDriver的工具类 public static WebDriver getPhantomJs() {   String osname = System.getProperties().getProperty("os.name");   if (osname.equals("Linux")) {//判断系统的环境win or Linux     System.setProperty("phantomjs.binary.path", "/usr/bin/phantomjs");   } else {     System.setProperty("phantomjs.binary.path", "./phantomjs/win/phantomjs.exe");//设置PhantomJs访问路径   }   DesiredCapabilities desiredCapabilities = DesiredCapabilities.phantomjs();   //设置参数   desiredCapabilities.setCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0");   desiredCapabilities.setCapability("phantomjs.page.customHeaders.User-Agent", "Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:50.0) Gecko/20100101   Firefox/50.0");   if (Constant.isProxy) {//是否使用代理     org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();     proxy.setProxyType(org.openqa.selenium.Proxy.ProxyType.MANUAL);     proxy.setAutodetect(false);     String proxyStr = "";     do {       proxyStr = ProxyUtil.getProxy();//自定义函数,返回代理ip及端口     } while (proxyStr.length() == 0);     proxy.setHttpProxy(proxyStr);     desiredCapabilities.setCapability(CapabilityType.PROXY, proxy);   }   return new PhantomJSDriver(desiredCapabilities); } 获取方式     try{     WebDriver webDriver = PhantomJsUtil.getPhantomJs();     webDriver.get(url);     SleepUtil.sleep(Constant.SEC_5);     PhantomJsUtil.screenshot(webDriver);     WebDriverWait wait = new WebDriverWait(webDriver, 10);     wait.until(ExpectedConditions.presenceOfElementLocated(By.id(inputId)));//开始打开网页,等待输入元素出现     Document document = Jsoup.parse(webDriver.getPageSource());     //TODO  剩下页面的获取就按照Jsoup获取方式来做   }finally{     if (webDriver != null) {       webDriver.quit();     }   } python版使用webdriver+PhantomJs爬虫使用,参考http://www.cnblogs.com/kuqs/p/6395284.html
2022-01-12 17:37:08 13.76MB 爬虫 1.9.8 1.9.7
1
20212022学年上海市松江区高三(上)期末历史试卷(一模)(附详解) .pdf
2022-01-12 14:03:17 2.18MB #资源达人分享计划#
高中历史学业水平测试复习提纲知识点精编版.pdf
2022-01-12 14:00:32 110KB 技术
寻找皇冠上的钻石——全球股票市场历史估值与回报率分析
2022-01-12 13:15:24 5.99MB 皇冠上的钻石
1
2022山西中考模拟百校联考一历史题借鉴.pdf
2022-01-12 09:10:29 470KB 网络文档
历史街区暑期认识实习考察报告.doc
2022-01-12 09:05:05 22KB 范文
历史久远的三叶石作文.doc
2022-01-12 09:05:05 20KB 范文
历史学专业实习鉴定.doc
2022-01-12 09:05:05 21KB 范文
历史研究性学习报告.doc
2022-01-12 09:05:04 26KB 范文