This commit is contained in:
2020-12-10 15:33:41 +01:00
parent 0f14fbb811
commit 7d0afec05b
3 changed files with 57 additions and 45 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ public class Main {
@Override
public void run() {
try {
WoSCrawler crawler = new WoSCrawler("\"" + Settings.WOSCATEGORY.getContent() + "\"", SearchMode.TOPIC, 0);
WoSCrawler crawler = new WoSCrawler("\"" + Settings.WOSCATEGORY.getContent() + "\"", SearchMode.TOPIC, 99000);
} catch (Exception e) {
e.printStackTrace();
}
+5 -4
View File
@@ -8,16 +8,16 @@ public enum Settings {
//Search Category
WOSCATEGORY("Computer systems based on specific mathematical models"),
WOSCATEGORY("A"),
USPTOCATEGORY("Administration; Management"),
GETCPCMAPPING("YES"),
GETCPCMAPPING("NO"),
DBCPC("CPC"),
COLLECTIONCPC("CPC"),
//WOS
//Starts the crawler
WOSSTARTDOWNLOAD("NO"),
WOSSTARTDOWNLOAD("YES"),
WOSSTARTIMPORT("NO"),
USERNAME("teddybond1@gmail.com"),
PASSWORD("K7.QW&34"),
@@ -43,7 +43,8 @@ public enum Settings {
DBPATENT("Patent"),
COLLECTIONPATENT("Patent"),
//Überspringt wait() --> Kann selbst fehler verursachen
DEBUG("NO"),
;
+51 -40
View File
@@ -46,19 +46,19 @@ public class WoSCrawler {
searchBox.sendKeys(currentSearch);
searchBox.submit();
wait(5000);
if (!Settings.DEBUG.getContent().equals("YES")) wait(5000);
}
private synchronized void searchComplex(String search) throws InterruptedException {
driver.findElement(By.cssSelector("a[title*=Advanced]")).click();
wait(1000);
if (!Settings.DEBUG.getContent().equals("YES")) wait(1000);
WebElement box = driver.findElement(By.cssSelector("textarea[class*=Adv_formBoxesSearch]"));
box.sendKeys(search);
wait(500);
if (!Settings.DEBUG.getContent().equals("YES")) wait(500);
driver.findElement(By.id("search-button")).click();
wait(1000);
if (!Settings.DEBUG.getContent().equals("YES")) wait(1000);
driver.findElement(By.id("hitCount")).click();
wait(5000);
if (!Settings.DEBUG.getContent().equals("YES")) wait(5000);
}
@@ -71,7 +71,7 @@ public class WoSCrawler {
driver.findElement(By.cssSelector("span[class*=onload-secondary-button")).click();
wait(1000);
if (!Settings.DEBUG.getContent().equals("YES")) wait(1000);
driver.findElement(By.id("numberOfRecordsRange")).click();
@@ -82,28 +82,26 @@ public class WoSCrawler {
setToMarkedList(min, max);
driver.findElement(By.cssSelector("button[class=onload-primary-button]")).click();
wait(30000);
if (!Settings.DEBUG.getContent().equals("YES")) wait(30000);
goAndPrepareMarked(max);
goAndPrepareMarked();
} else {
setToMarkedList(min, max);
driver.findElement(By.cssSelector("button[class=onload-primary-button]")).click();
wait(30000);
if (!Settings.DEBUG.getContent().equals("YES")) wait(30000);
goAndPrepareMarked(max);
goAndPrepareMarked();
goToSeachPage();
min = max;
max = maxCount;
setToMarkedList(min, max);
driver.findElement(By.cssSelector("button[class=onload-primary-button]")).click();
wait(30000);
if (!Settings.DEBUG.getContent().equals("YES")) wait(30000);
goAndPrepareMarked(max);
goAndPrepareMarked();
}
}
private void setToMarkedList(int min, int max) throws InterruptedException {
@@ -112,56 +110,62 @@ public class WoSCrawler {
from.clear();
to.clear();
from.sendKeys(String.valueOf(min));
wait(500);
if (!Settings.DEBUG.getContent().equals("YES")) wait(500);
to.sendKeys(String.valueOf(max));
}
private void goAndPrepareMarked(int maxNumber) throws InterruptedException {
private void goAndPrepareMarked() throws InterruptedException {
driver.findElement(By.cssSelector("a[title*=Marked")).click();
wait(1000);
if (!Settings.DEBUG.getContent().equals("YES")) wait(1000);
driver.findElement(By.id("value(select_All)")).click();
wait(590);
if (!Settings.DEBUG.getContent().equals("YES")) wait(590);
driver.findElement(By.id("ISSN_fields")).click();
wait(540);
if (!Settings.DEBUG.getContent().equals("YES")) wait(540);
driver.findElement(By.id("ACCESSION_NUM_fields")).click();
wait(513);
if (!Settings.DEBUG.getContent().equals("YES")) wait(513);
driver.findElement(By.id("ADDRS_fields")).click();
wait(513);
if (!Settings.DEBUG.getContent().equals("YES")) wait(513);
driver.findElement(By.id("IDS_fields")).click();
wait(513);
if (!Settings.DEBUG.getContent().equals("YES")) wait(513);
driver.findElement(By.id("PMID_fields")).click();
wait(513);
if (!Settings.DEBUG.getContent().equals("YES")) wait(513);
driver.findElement(By.id("OPEN_ACCESS_fields")).click();
wait(513);
if (!Settings.DEBUG.getContent().equals("YES")) wait(513);
driver.findElement(By.id("SABBR_fields")).click();
wait(513);
if (!Settings.DEBUG.getContent().equals("YES")) wait(513);
driver.findElement(By.id("AUTHORSIDENTIFIERS_fields")).click();
wait(513);
if (!Settings.DEBUG.getContent().equals("YES")) wait(513);
driver.findElement(By.id("CONFERENCE_SPONSORS_fields")).click();
wait(513);
if (!Settings.DEBUG.getContent().equals("YES")) wait(513);
WebElement amount = driver.findElement(By.cssSelector("span[class=umlProdListText]"));
String text = amount.getText();
text = text.replace(" total records on the Marked List", "").replace(",", "");
int amountInt = Integer.valueOf(text.trim());
int min = 1;
int max = 0;
if (maxNumber < 499) {
export(1, maxNumber);
if (amountInt < 499) {
export(1, amountInt);
clearMarkedList();
return;
}
while (max + 499 < maxNumber) {
wait(10000);
while (max + 499 < amountInt) {
if (!Settings.DEBUG.getContent().equals("YES")) wait(10000);
export(min, max + 499);
min = min + 499;
max = max + 499;
}
export(min, maxNumber);
if (min != amountInt) {
export(min, amountInt);
}
clearMarkedList();
}
private void clearMarkedList() throws InterruptedException {
driver.findElement(By.cssSelector("button[class*=snowplow-wos-markedlist-clear-click")).click();
wait(500);
if (!Settings.DEBUG.getContent().equals("YES")) wait(500);
driver.switchTo().alert().accept();
}
@@ -175,25 +179,32 @@ public class WoSCrawler {
WebElement to = driver.findElement(By.id("markTo"));
to.clear();
WebElement amount = driver.findElement(By.cssSelector("span[class=umlProdListText]"));
String text = amount.getText();
text = text.replace(" total records on the Marked List", "").replace(",", "");
int amountInt = Integer.valueOf(text.trim());
if (start + amountInt < end) {
end = start + amountInt - 1;
}
from.sendKeys(String.valueOf(start));
wait(512);
if (!Settings.DEBUG.getContent().equals("YES")) wait(512);
to.sendKeys(String.valueOf(end));
driver.findElement(By.id("record_select_type_range")).click();
wait(1056);
if (!Settings.DEBUG.getContent().equals("YES")) wait(1056);
if (driver.findElements(By.id("exportTypeName")).size() != 0) {
driver.findElement(By.id("exportTypeName")).click();
wait(1056);
if (!Settings.DEBUG.getContent().equals("YES")) wait(1056);
driver.findElement(By.cssSelector("a[name*=Excel")).click();
} else {
driver.findElement(By.cssSelector("button[title*=Excel]")).click();
}
wait(981);
if (!Settings.DEBUG.getContent().equals("YES")) wait(981);
driver.findElement(By.cssSelector("button[name=saveToExcel")).click();
wait((int) (60000 + Math.random() * 10000)); //Erhöhen
if (!Settings.DEBUG.getContent().equals("YES")) wait((int) (60000 + Math.random() * 10000)); //Erhöhen
}
@@ -235,7 +246,7 @@ public class WoSCrawler {
buttons.get(0).click();
WebElement button = driver.findElement(By.cssSelector("li[class=select2-results__option]"));
button.click();
wait(1000);
if (!Settings.DEBUG.getContent().equals("YES")) wait(1000);
}