request.getSession().getServletContext().getRealPath("/uploadfile/article"); 得到保存目录的真实路径request.getServletContext().getRealPath("/") 类似上面,获取项目所在服务器的全路径,如:D:\Program Files\apache-tomcat-7.0.25\webapps\TestSytem\request.getServletPath() 获取客户端请求的路径名,如:/object/delObject 就是除域名主体额外的部分request.getContextPath() 虚拟目录request.getSession().getServletContext().getContextPath() 也可以获得虚拟目录request.getServerName() 获取服务器地址,如:localhost request.getServerPort() 获取服务器端口,如8080request.getContextPath() 获取项目名称,如:TestSytemrequest.getLocalAddr() 获取本地地址,如:127.0.0.1request.getLocalName() 获取本地IP映射名,如:localhostrequest.getLocalPort() 获取本地端口,如:8090request.getRealPath("/") 获取项目所在服务器的全路径,如:D:\Program Files\apache-tomcat-7.0.25\webapps\TestSytem\request.getRemoteAddr() 获取远程主机地址,如:127.0.0.1request.getRemoteHost() 获取远程主机,如:127.0.0.1request.getRemotePort() 获取远程客户端端口,如:3623request.getRequestedSessionId() 获取会话session的ID,如:823A6BACAC64FB114235CBFE85A46CAArequest.getRequestURI() 获取包含项目名称的请求路径,如:/TestSytem/object/delObjectrequest.getRequestURL().toString() 获取请求的全路径,如:http://localhost:8090/TestSytem/object/delObject
所需依赖:servlet-api @RequestMapping("/getPost") public String getJson(HttpServletRequest request) throws IOException { String sret = null; String ContentType = ""; ContentType = request.getHeader("Content-Type"); if (ContentType.equalsIgnoreCase("application/x-www-form-urlencoded")) {// 这里Map中的泛型最好写上 方便idea自动生成entries Map<String, String[]> params = request.getParameterMap();// Set泛型写上才可以遍历entries Set<Map.Entry<String, String[]>> entries = params.entrySet(); String queryString = ""; for (String key : params.keySet()) { String[] values = params.get(key); for (int i = 0; i < values.length; i++) { String value = values[i]; queryString += key + "=" + value + "&"; } } if (queryString.length() > 1) { // 去掉最后一个空格 queryString = queryString.substring(0, queryString.length() - 1); } sret = queryString; } else if (ContentType.equalsIgnoreCase("multipart/form-data")) { try { StringBuffer info = new StringBuffer(); ServletInputStream in = request.getInputStream(); BufferedInputStream buf = new BufferedInputStream(in); byte[] buffer = new byte[1024]; int iRead; while ((iRead = buf.read(buffer)) != -1) { info.append(new String(buffer, 0, iRead, "UTF-8")); sret = info.toString(); } } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { } return sret; } @RequestMapping("/get") public static String getGetParam(HttpServletRequest request) { String sret = null; String queryString = null;//只能获取get参数 queryString = request.getQueryString(); sret = queryString; return sret; }
remove.bg中文:点击进入在线抠图阿里巴巴的需要淘宝号登陆才可使用,否则会提示图片上传失败:阿里巴巴在线抠图当然扣好图也方便做证件照了
开始准备Chromechromedriver驱动(下载不同版本浏览器对应驱动教程)代码pom依赖:<dependencies> <!--添加浏览器驱动--> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-server</artifactId> <version>3.141.59</version> </dependency> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>4.5.6</version> </dependency></dependencies>Main代码:import cn.hutool.core.date.DateUtil;import cn.hutool.core.lang.Console;import cn.hutool.core.util.StrUtil;import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.openqa.selenium.WebElement;import org.openqa.selenium.chrome.ChromeDriverService;import org.openqa.selenium.remote.DesiredCapabilities;import org.openqa.selenium.remote.RemoteWebDriver;import java.io.File;import java.io.IOException;import java.util.ArrayList;public class LagouSpider { private static ArrayList<String> strings = new ArrayList<>(); public static void main(String[] args) { String webDriverPath = LagouSpider.class.getResource("chromedriver.exe").getPath(); // 这里需要注意一定要和打开的Chrome版本匹配 System.setProperty("webdriver.chrome.driver", webDriverPath); // 构建驱动 ChromeDriverService service = new ChromeDriverService.Builder(). usingDriverExecutable(new File(webDriverPath)).usingAnyFreePort().build(); try { service.start(); } catch (IOException e) { e.printStackTrace(); } // 获取Web驱动 WebDriver driver = new RemoteWebDriver(service.getUrl(), DesiredCapabilities.chrome()); String url = "https://tophub.today/"; // 访问页面 driver.get(url); for (int i = 0; i < 200; i++) { for (int j = 0; j <= 10; j++) { try { run(driver, webDriverPath, url, i, j); } catch (Exception e) { continue; } } } Console.log(strings); // 退出驱动线程 driver.quit(); // 关闭service服务 service.stop(); } public static void run(WebDriver driver, String webDriverPath, String url, int i, int j) { String titleExpression = "//div[@id='node-" + i + "']/div/div[contains(@class, 'cc-cd-ih')]/div[contains(@class, 'cc-cd-is')]/a/div[contains(@class, 'cc-cd-lb')]"; String contentExpression = "//div[@id='node-" + i + "']/div/div[contains(@class, 'cc-cd-cb nano has-scrollbar')]/div[contains(@class, 'cc-cd-cb-l nano-content')]/a[" + j + "]/div[contains(@class, 'cc-cd-cb-ll')]/span[contains(@class, 't')]"; // 获取标题 WebElement titleElement = driver.findElement(By.xpath(titleExpression)); String titleElementText = titleElement.getText(); if (StrUtil.isNotEmpty(titleElementText)) { boolean hasStr = -1 == strings.indexOf(titleElementText); if (hasStr) { strings.add(titleElementText); Console.log(StrUtil.format("[{}]", titleElementText)); } WebElement textChildEle = driver.findElement(By.xpath(contentExpression)); if (StrUtil.isNotEmpty(textChildEle.getText())) { Console.log(StrUtil.format("\t[{}]\t[{}]({})", DateUtil.now(), textChildEle.getText()), textChildEle.findElement(By.xpath("//div[@id='node-" + i + "']/div/div[contains(@class, 'cc-cd-cb nano has-scrollbar')]/div[contains(@class, 'cc-cd-cb-l nano-content')]/a[" + j + "]")).getAttribute("href")); } /*try { Thread.sleep(1000L); } catch (InterruptedException e) { Console.error("Thread sleep Error"); }*/ } // 获取内容列表 /*List<WebElement> textParentEle = driver.findElements(By.xpath(contentExpression)); for (WebElement textChildEle : textParentEle) { WebElement childEleElement = textChildEle.findElement(By.className("t")); boolean isEmptyForText = StrUtil.isEmpty(childEleElement.getText()); if (isEmptyForText) { continue; } Console.log(StrUtil.format("\t[{}]\t[{}]\r\n", DateUtil.now(), textChildEle.getText())); }*/ }}其中相关于XPath知识请 进入查看Xpath相关:https://blog.csdn.net/u011541946/article/details/73323911https://blog.csdn.net/u011541946/article/details/67639423
1、安装谷歌Chrome浏览器2、安装谷歌访问助手链接:https://pan.baidu.com/s/1oYSZijMJ7Xp5bdrrbRXNWA 提取码:fw33 3、在谷歌浏览器自带的插件商城里搜索tampermonkey安装即可手机上可以下载火狐浏览器,在附加组件里找到tampermonkey安装即可,安装油猴脚本同上。油猴的官网:https://www.tampermonkey.net/ 油猴脚本下载:https://greasyfork.org/zh-CN/scripts
在UCAN 2019设计大会上,阿里巴巴对外发布了一款全新免费字体——阿里巴巴普惠体,并表示:“希望阿里巴巴的普惠精神,可以让整个生态的设计师、合作伙伴因为我们平台的赋能,真正得到实惠”。据官方介绍,阿里巴巴普惠体是一款由中国企业首发,可面向全场景使用的免费商用征文字体。目前,该字体共收录116895个全形汉字(含5个字重)、7205个拉丁字母(2种风格、共11个字重)、并覆盖172个语种,以满足阿里巴巴集团及其经济体公司在多个场景下的使用需求。链接:https://pan.baidu.com/s/1LhJ6v25Pvfn25EwDXcs4hg提取码:ukgs 也可以至官网下载:https://alibabafont.taobao.com/
下载:https://www.lanzoux.com/i3m1ipe支持所有jetbrains旗下软件,包括IDEA,PyCharm,PHP等。WIN7 WIN10汉化:jar文件就是汉化包,把文件直接放到目录下的lib(是lib文件夹 不是bin文件夹)文件夹里即可完美汉化。-----------------------------------------------------------------------------------------------mac汉化:经过提交官网优化,已经完美支持打开设置,并支持mac系统。 1.右键点击PyCharm,选择显示包内容。 2.选择如下路径/Applications/PyCharm.app/Contents/lib 3.将下载的resources_cn.jar 复制进去 4.将之前的resources_en.jar 改成其他名字。