|
@@ -373,8 +373,9 @@ public class UploadFromWebService {
|
|
|
}
|
|
|
|
|
|
//等待直到出现a标签为"检 索"的元素,找到该元素并将鼠标悬停其上(自动展开二级子菜单),找到a标签为"高级检索"的元素并点击
|
|
|
- wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#container > div:nth-child(1) > div.top > div.top_con > div.menu > ul > li:nth-child(2) > a")));
|
|
|
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("检 索")));
|
|
|
action.moveToElement(driver.findElement(By.linkText("检 索"))).perform();
|
|
|
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("高级检索")));
|
|
|
driver.findElement(By.linkText("高级检索")).click();
|
|
|
|
|
|
//等待直到出现id为"textarea"的元素,找到该元素并输入内容conditions,找到检索按钮的css路径并点击(即检索框中输入内容检索)
|
|
@@ -382,7 +383,99 @@ public class UploadFromWebService {
|
|
|
driver.findElement(By.id("textarea")).sendKeys(conditions);
|
|
|
driver.findElement(By.cssSelector("#instructSearchDiv > div.button.citation_btn > input.retrieval")).click();
|
|
|
|
|
|
- //
|
|
|
+ //获得当前主窗口的句柄,并存入map集合中
|
|
|
+ String mainWindowHandle = driver.getWindowHandle();
|
|
|
+ HashMap<String, String> windowHandleMap = new HashMap<>();
|
|
|
+ windowHandleMap.put("mainPage", mainWindowHandle);
|
|
|
+
|
|
|
+ //等待直到出现class为"patent_information"的元素,再线程睡眠5秒等待所有的该元素都加载完,找到所有的该元素(即找到所有专利)
|
|
|
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.className("patent_information")));
|
|
|
+ Thread.sleep(5000);
|
|
|
+ List<WebElement> patentContents = driver.findElements(By.className("patent_information"));
|
|
|
+
|
|
|
+ //遍历专利
|
|
|
+ for (WebElement patentContent : patentContents) {
|
|
|
+ PatentCell patentCell = new PatentCell()
|
|
|
+ .setProjectId(webQueryDTO.getProjectId())
|
|
|
+ .setReportId(webQueryDTO.getReportId());
|
|
|
+ //等待直到出现class为"highlight_All"的元素,找到该元素并点击(即点击专利的抬头标题),页面跳转到了该专利详情页面
|
|
|
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.className("highlight_ALL")));
|
|
|
+ driver.findElement(By.className("highlight_ALL")).click();
|
|
|
+ //找到当前所有窗口句柄,遍历找到该专利详情页面的窗口句柄,存入map集合中
|
|
|
+ Set<String> windowHandles = driver.getWindowHandles();
|
|
|
+ for (String windowHandle : windowHandles) {
|
|
|
+ if (!windowHandle.equals(mainWindowHandle)) {
|
|
|
+ windowHandleMap.put("patentDetailPage", windowHandle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //页面跳转到该专利详情页面
|
|
|
+ driver.switchTo().window(windowHandleMap.get("patentDetailPage"));
|
|
|
+ //等待直到出现css路径为第一个table标签的元素"著录项目",找到该元素并在该元素中找到所有"tr"标签元素,遍历tr元素装载专利相关信息数据
|
|
|
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#context > div:nth-child(3) > div:nth-child(1) > div > table")));
|
|
|
+ WebElement table1 = driver.findElement(By.cssSelector("#context > div:nth-child(3) > div:nth-child(1) > div > table"));
|
|
|
+ List<WebElement> trs = table1.findElements(By.tagName("tr"));
|
|
|
+ for (WebElement tr : trs) {
|
|
|
+ String text = tr.getText();
|
|
|
+ if (text.contains("申请号")) {
|
|
|
+ patentCell.setApplicationNo(text.substring(4));
|
|
|
+ } else if (text.contains("申请日")) {
|
|
|
+ patentCell.setApplications(text.substring(4));
|
|
|
+ } else if (text.contains("公开(公告)号")) {
|
|
|
+ patentCell.setPublicNo(text.substring(8));
|
|
|
+ } else if (text.contains("公开(公告)日")) {
|
|
|
+ patentCell.setPubilcDate(text.substring(8));
|
|
|
+ } else if (text.contains("优先权信息")) {
|
|
|
+ patentCell.setPriorityInformation(text.substring(6));
|
|
|
+ } else if (text.contains("预估到期日")) {
|
|
|
+ patentCell.setEstimatedMaturityDate(text.substring(6));
|
|
|
+ } else if (text.contains("申请人(原始)\n")) {
|
|
|
+ String applicationPerson = text.substring(8, text.lastIndexOf(";"));
|
|
|
+ ArrayList<String> applicationPersons = new ArrayList<>();
|
|
|
+ applicationPersons.add(applicationPerson);
|
|
|
+ patentCell.setApplicationPersons(applicationPersons);
|
|
|
+ } else if (text.contains("标准申请人\n")) {
|
|
|
+ String applicationPerson = text.substring(6, text.lastIndexOf(";"));
|
|
|
+ List<String> applicationPersons;
|
|
|
+ if (patentCell.getApplicationPersons() != null) {
|
|
|
+ applicationPersons = patentCell.getApplicationPersons();
|
|
|
+ applicationPersons.add(applicationPerson);
|
|
|
+ } else {
|
|
|
+ applicationPersons = new ArrayList<>();
|
|
|
+ applicationPersons.add(applicationPerson);
|
|
|
+ patentCell.setApplicationPersons(applicationPersons);
|
|
|
+ }
|
|
|
+ } else if (text.contains("申请人地址")) {
|
|
|
+ String applicationAddressStr = text.substring(6);
|
|
|
+ ArrayList<String> applicationAddress = new ArrayList<>();
|
|
|
+ applicationAddress.add(applicationAddressStr);
|
|
|
+ patentCell.setApplicationAddress(applicationAddress);
|
|
|
+ } else if (text.contains("当前权利人\n")) {
|
|
|
+ String applicationCurrent = text.substring(6, text.lastIndexOf(";"));
|
|
|
+ ArrayList<String> applicationCurrents = new ArrayList<>();
|
|
|
+ applicationCurrents.add(applicationCurrent);
|
|
|
+ patentCell.setApplicationCurrents(applicationCurrents);
|
|
|
+ } else if (text.contains("标准化当前权利人")) {
|
|
|
+ String applicationCurrent = text.substring(9);
|
|
|
+ List<String> applicationCurrents;
|
|
|
+ if (patentCell.getApplicationCurrents() != null) {
|
|
|
+ applicationCurrents = patentCell.getApplicationCurrents();
|
|
|
+ applicationCurrents.add(applicationCurrent);
|
|
|
+ } else {
|
|
|
+ applicationCurrents = new ArrayList<>();
|
|
|
+ applicationCurrents.add(applicationCurrent);
|
|
|
+ patentCell.setApplicationCurrents(applicationCurrents);
|
|
|
+ }
|
|
|
+ } else if (text.contains("发明人(原始)")) {
|
|
|
+ String[] inventorsStr = text.substring(8).split("; ");
|
|
|
+ ArrayList<String> inventors = new ArrayList<>(Arrays.asList(inventorsStr));
|
|
|
+ patentCell.setInventors(inventors);
|
|
|
+ } else if (text.contains("权利要求数量")) {
|
|
|
+ patentCell.setRightsNum(text.substring(7));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println(patentCell);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
return null;
|
|
|
|
|
@@ -506,14 +599,14 @@ public class UploadFromWebService {
|
|
|
StringBuilder stringBuilder = new StringBuilder("(" + params[1]);
|
|
|
stringBuilder.append("/");
|
|
|
String cell = jsonObject.get(params[0]).toString();
|
|
|
- stringBuilder.append(cell + ")");
|
|
|
+ stringBuilder.append(cell).append(")");
|
|
|
return stringBuilder.toString();
|
|
|
}
|
|
|
|
|
|
//将值转换为list
|
|
|
public List<String> StringToList(String value, String split) {
|
|
|
List<String> list = new ArrayList<>();
|
|
|
- if (value != null && value != "") {
|
|
|
+ if (value != null && !value.equals("")) {
|
|
|
String[] temValue = value.split(split);
|
|
|
list = new ArrayList<>(Arrays.asList(temValue));
|
|
|
}
|