Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abb3833ebe |
@@ -20,8 +20,8 @@ public class WebOfScienceCrawler {
|
||||
private static final int MARKED_LIST_MAX = 50000;
|
||||
private static final int WOS_RECORD_LIMIT = 100000;
|
||||
private static final int RECORDS_MAX = 500;
|
||||
private static final int PUB_YEAR_START = 2010;
|
||||
private static final int PUB_YEAR_END = 2020;
|
||||
private static final int PUB_YEAR_START = 2011;
|
||||
private static final int PUB_YEAR_END = 2021;
|
||||
private static final String PUB_YEAR_RESEARCH_SPAN = "(1900-2020)";
|
||||
|
||||
private final boolean statisticsFlag = false;
|
||||
@@ -55,9 +55,12 @@ public class WebOfScienceCrawler {
|
||||
System.setProperty("webdriver.gecko.driver", "src/main/java/de/nes/guide/wos/util/geckodriver.exe");
|
||||
profile = new FirefoxProfile();
|
||||
options = new FirefoxOptions();
|
||||
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf;application/vnd.ms-excel;application/excel;text/plain;text/html;application/text;text/xml;application/xml");
|
||||
profile.setPreference("browser.download.folderList", 2);
|
||||
profile.setPreference("browser.download.dir","C:\\Guide Data\\testi");
|
||||
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf;application/vnd.ms-excel;application/excel;text/plain;text/html;application/text;text/xml;application/xml;application/x-Inst-for-Scientific-Info;charset=utf-8");
|
||||
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
|
||||
options.setProfile(profile);
|
||||
options.setHeadless(true);
|
||||
driver = new FirefoxDriver(options);
|
||||
EventFiringWebDriver eventDriver = new EventFiringWebDriver(driver);
|
||||
eventDriver.register(new CostomDriverListener());
|
||||
@@ -109,7 +112,7 @@ public class WebOfScienceCrawler {
|
||||
if (driver.findElements(By.xpath(element)).size() > 0) {
|
||||
driver.findElement(By.xpath(element)).click();
|
||||
} else {
|
||||
checkAndRedirectPage(driver);
|
||||
//checkAndRedirectPage(driver);
|
||||
}
|
||||
} else {
|
||||
driver.findElement(By.xpath(element)).click();
|
||||
@@ -125,7 +128,7 @@ public class WebOfScienceCrawler {
|
||||
if (driver.findElements(By.cssSelector(element)).size() > 0) {
|
||||
driver.findElement(By.cssSelector(element)).click();
|
||||
} else {
|
||||
checkAndRedirectPage(driver);
|
||||
//checkAndRedirectPage(driver);
|
||||
}
|
||||
} else {
|
||||
driver.findElement(By.cssSelector(element)).click();
|
||||
@@ -148,7 +151,9 @@ public class WebOfScienceCrawler {
|
||||
driver.navigate().to(WOS_URL);
|
||||
checkWOSLogin(driver);
|
||||
changeToAdvancedSearchTab(driver);
|
||||
performAdvancedSearch(driver);
|
||||
//performAdvancedSearch(driver);
|
||||
performAdvancedSearchforDUE(driver);
|
||||
//performAdvancedSearchComputerScience(driver);
|
||||
terminateDriver(driver);
|
||||
fileWriter.cleanUpFileWriter();
|
||||
} catch (Exception e) {
|
||||
@@ -157,6 +162,17 @@ public class WebOfScienceCrawler {
|
||||
}
|
||||
}
|
||||
|
||||
private void performAdvancedSearchforDUE(FirefoxDriver driver) {
|
||||
performingExport = true;
|
||||
for (int year = PUB_YEAR_START; year <= PUB_YEAR_END; year++){
|
||||
currentYear = year;
|
||||
buildQueryAndPerformAdvancedSearch(driver, "dummy");
|
||||
startingRecord50ks = 1;
|
||||
startingRecord500s = 1;
|
||||
}
|
||||
performingExport = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* This method quites the firefox driver
|
||||
*/
|
||||
@@ -170,16 +186,21 @@ public class WebOfScienceCrawler {
|
||||
* */
|
||||
private void selectResultsforMarkedList(FirefoxDriver driver) {
|
||||
int numberOfRecords = 0;
|
||||
if (performingExport) {
|
||||
numberOfRecords = Integer.parseInt(driver.findElement(By.xpath("//*[@id=\"hitCount.top\"]")).getText().replace(",", "")) - (startingRecord50ks - 1);
|
||||
} else {
|
||||
numberOfRecords = Integer.parseInt(driver.findElement(By.xpath("//*[@id=\"hitCount.top\"]")).getText().replace(",", ""));
|
||||
}
|
||||
numberOfRecords = Integer
|
||||
.parseInt(driver.findElement(By.xpath("//*[@id=\"hitCount.top\"]")).getText().replace(",", ""));
|
||||
System.out.println("Total number of records for this field: " + numberOfRecords);
|
||||
int quotient = numberOfRecords / MARKED_LIST_MAX;
|
||||
int remainder = numberOfRecords % MARKED_LIST_MAX;
|
||||
if (numberOfRecords > WOS_RECORD_LIMIT)
|
||||
numberOfRecords = WOS_RECORD_LIMIT;
|
||||
System.out.println(quotient + "/" + remainder);
|
||||
if(quotient > 1 && numberOfRecords >= MARKED_LIST_MAX * 2 && startingRecord50ks == 1) {
|
||||
quotient = 2;
|
||||
remainder = 0;
|
||||
}else if (quotient > 1 && numberOfRecords >= MARKED_LIST_MAX * 2 && startingRecord50ks >= MARKED_LIST_MAX){
|
||||
quotient = 1;
|
||||
}
|
||||
else if (startingRecord50ks >= MARKED_LIST_MAX && numberOfRecords < MARKED_LIST_MAX * 2){
|
||||
quotient = 0;
|
||||
}
|
||||
if (numberOfRecords <= MARKED_LIST_MAX) {
|
||||
performMarkedList(driver, startingRecord50ks, (startingRecord50ks + numberOfRecords - 1));
|
||||
} else {
|
||||
@@ -190,7 +211,7 @@ public class WebOfScienceCrawler {
|
||||
}
|
||||
if (remainder != 0) {
|
||||
startingRecord500s = 1;
|
||||
performMarkedList(driver, startingRecord50ks, numberOfRecords);
|
||||
performMarkedList(driver, startingRecord50ks,numberOfRecords);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,7 +221,7 @@ public class WebOfScienceCrawler {
|
||||
* */
|
||||
private void performMarkedList(FirefoxDriver driver, int startingRecord, int numberOfRecords) {
|
||||
System.out.println(driver.getTitle());
|
||||
simulateUserWait(15);
|
||||
simulateUserWait(10);
|
||||
if(sortByCitedOnce){
|
||||
driver.findElement(By.cssSelector("div.paginationBar:nth-child(2) > div:nth-child(4) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > form:nth-child(1) > div:nth-child(7) > li:nth-child(3)")).click();
|
||||
sortByCitedOnce = false;
|
||||
@@ -285,7 +306,7 @@ public class WebOfScienceCrawler {
|
||||
* */
|
||||
private void performExport(FirefoxDriver driver, int startingRecord, int endingRecord) {
|
||||
System.out.println(driver.getTitle());
|
||||
System.out.println("exporting records from " + startingRecord + " to " + endingRecord);
|
||||
System.out.println("exporting records from " + startingRecord + " to " + endingRecord + "for year: "+ currentYear );
|
||||
simulateUserWait(5);
|
||||
checkElementAvailabilityPerXpath(driver, "//*[@id=\"record_select_type_range\"]");
|
||||
WebElement selectAllCharacteristicsCheckbox = driver.findElement(By.cssSelector("#value\\(select_All\\)"));
|
||||
@@ -304,6 +325,27 @@ public class WebOfScienceCrawler {
|
||||
simulateUserWait(3);
|
||||
toRecord.sendKeys(Integer.toString(endingRecord));
|
||||
simulateUserWait(3);
|
||||
/* endnote
|
||||
if (driver.findElements(By.id("exportTypeName")).size() > 0) {
|
||||
String buttonText = driver.findElement(By.id("exportTypeName")).getText().toLowerCase();
|
||||
if (!buttonText.contains("endnote")) {
|
||||
driver.findElement(By.id("exportTypeName")).click();
|
||||
simulateUserWait(5);
|
||||
driver.findElement(By.cssSelector("a[name*=EndNote]")).click();
|
||||
simulateUserWait(2);
|
||||
//driver.findElement(By.cssSelector("#exportButton")).click();
|
||||
} else {
|
||||
driver.findElement(By.id("exportTypeName")).click();
|
||||
simulateUserWait(6);
|
||||
}
|
||||
} else {
|
||||
driver.findElement(By.cssSelector("button.quickOutputEndNote")).click();
|
||||
simulateUserWait(6);
|
||||
}
|
||||
simulateUserWait(6);
|
||||
//driver.findElement(By.cssSelector("button[name=saveToEndNote]")).click();
|
||||
*/
|
||||
//excel
|
||||
if (driver.findElements(By.id("exportTypeName")).size() > 0) {
|
||||
String buttonText = driver.findElement(By.id("exportTypeName")).getText().toLowerCase();
|
||||
if (!buttonText.contains("excel")) {
|
||||
@@ -345,6 +387,17 @@ public class WebOfScienceCrawler {
|
||||
deleteHitsButton.click();
|
||||
}
|
||||
|
||||
private void performAdvancedSearchComputerScience(FirefoxDriver driver) {
|
||||
performingExport = true;
|
||||
for (int year = currentYear; year <= PUB_YEAR_END; year++){
|
||||
currentYear = year;
|
||||
buildQueryAndPerformAdvancedSearch(driver, fieldStatus);
|
||||
startingRecord50ks = 1;
|
||||
startingRecord500s = 1;
|
||||
}
|
||||
performingExport = false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This method performs the prepares the process based on the given fields
|
||||
@@ -385,7 +438,8 @@ public class WebOfScienceCrawler {
|
||||
WebElement advancedSearchFormButton = driver.findElement(By.xpath("//*[@id=\"search-button\"]"));
|
||||
advancedTextArea.sendKeys(Keys.TAB);
|
||||
advancedTextArea.clear();
|
||||
String query = buildAdvancedQuery(field);
|
||||
//String query = buildAdvancedQuery(field);
|
||||
String query = buildAdvancedQueryforDUE();
|
||||
|
||||
simulateUserWait(3);
|
||||
advancedTextArea.sendKeys(query);
|
||||
@@ -405,6 +459,19 @@ public class WebOfScienceCrawler {
|
||||
|
||||
}
|
||||
|
||||
private String buildAdvancedQueryforDUE() {
|
||||
System.out.println("Adding DUE data to marked list");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(FieldTag.ORGANIZATION_ENHANCED.getTag())
|
||||
.append(FieldTag.EQUAL.getTag())
|
||||
.append("University of Duisburg Essen")
|
||||
.append(FieldTag.AND.getTag())
|
||||
.append(FieldTag.YEAR_PUBLISHED.getTag())
|
||||
.append(FieldTag.EQUAL.getTag())
|
||||
.append(currentYear);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* This method counts out the number of records per field, with the corresponding "OpenAccess" ones
|
||||
* It also writes this info in a CSV data for later analysis
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
Field;records;OpenAccess;;SUM;;
|
||||
Architecture;157184;9772;;100090806;;
|
||||
"Agriculture ";1258250;268126;;;;
|
||||
Astronomy & Astrophysics;704392;205797;;;133,454408; Number of days needed
|
||||
Archaeology;135733;9936;;;;
|
||||
Acoustics;197357;31864;;;;
|
||||
Art;331346;10018;;;;
|
||||
Allergy;181079;20917;;;;
|
||||
Chemistry;6557397;602901;;;;
|
||||
Area Studies;233337;15456;;;;
|
||||
Automation & Control Systems;241646;17491;;;;
|
||||
Arts & Humanities Other Topics;762735;47240;;;;
|
||||
Anatomy & Morphology;145980;16638;;;;
|
||||
Crystallography;334669;69155;;;;
|
||||
Biomedical Social Sciences;135483;27443;;;;
|
||||
Computer Science;1454122;219190;;;;
|
||||
Asian Studies;126883;5946;;;;
|
||||
Anesthesiology;276793;61569;;;;
|
||||
Electrochemistry;322667;21693;;;;
|
||||
Business & Economics;1608648;190585;;;;
|
||||
Construction & Building Technology;179249;16070;;;;
|
||||
Classics;110952;3321;;;;
|
||||
Anthropology;303895;25726;;;;
|
||||
Geochemistry & Geophysics;400153;62025;;;;
|
||||
Communication;161620;23340;;;;
|
||||
Energy & Fuels;627276;65401;;;;
|
||||
Audiology & Speech-Language Pathology;104950;20390;;;;
|
||||
Geology;714303;133921;;;;
|
||||
Engineering;5759153;583577;;;;
|
||||
Film, Radio & Television;156577;3472;;;;
|
||||
Behavioral Sciences;240493;43763;;;;
|
||||
Mathematics;1751209;400913;;;;
|
||||
Imaging Science & Photographic Technology;100530;9554;;;;
|
||||
History;1199348;76956;;;;
|
||||
Biochemistry & Molecular Biology;3073455;811653;;;;
|
||||
Meteorology & Atmospheric Sciences;344571;135819;;;;
|
||||
Information Science & Library Science;444958;35208;;;;
|
||||
History & Philosophy of Science;149771;18349;;;;
|
||||
Biodiversity & Conservation;130093;29642;;;;
|
||||
Mineralogy;103740;10164;;;;
|
||||
Instruments & Instrumentation;556652;65275;;;;
|
||||
Literature;1388359;37827;;;;
|
||||
Biophysics;712286;147327;;;;
|
||||
Education & Educational Research;858361;122709;;;;
|
||||
Materials Science;2961158;333238;;;;
|
||||
Music;364074;5754;;;;
|
||||
Biotechnology & Applied Microbiology;757383;256049;;;;
|
||||
Oceanography;218548;63059;;;;
|
||||
Mechanics;536433;43851;;;;
|
||||
Philosophy;483597;48796;;;;
|
||||
Cardiovascular System & Cardiology;1666052;378169;;;;
|
||||
Optics;718165;115827;;;;
|
||||
Metallurgy & Metallurgical Engineering;654820;63696;;;;
|
||||
Religion;384368;24365;;;;
|
||||
Cell Biology;1391609;426015;;;;
|
||||
Physical Geography;127624;23238;;;;
|
||||
Geography;383771;45467;;;;
|
||||
Theater;101539;2285;;;;
|
||||
Physics;4839924;468020;;;;
|
||||
Government & Law;1063190;57405;;;;
|
||||
Nuclear Science & Technology;449361;22319;;;;
|
||||
Dentistry, Oral Surgery & Medicine;430892;48663;;;;
|
||||
Polymer Science;589737;52366;;;;
|
||||
International Relations;251637;15259;;;;
|
||||
Operations Research & Management Science;238725;18530;;;;
|
||||
Dermatology;483880;54901;;;;
|
||||
Thermodynamics;315692;25133;;;;
|
||||
Linguistics;398325;40606;;;;
|
||||
Developmental Biology;184639;52093;;;;
|
||||
Water Resources;334249;54790;;;;
|
||||
Emergency Medicine;119251;22943;;;;
|
||||
Psychology;1883657;236522;;;;
|
||||
Science & Technology Other Topics;2615136;884902;;;;
|
||||
Endocrinology & Metabolism;920979;186870;;;;
|
||||
Public Administration;204000;13681;;;;
|
||||
Spectroscopy;251668;16414;;;;
|
||||
Entomology;265441;35304;;;;
|
||||
Social Issues;172513;13339;;;;
|
||||
Telecommunications;455745;86332;;;;
|
||||
Environmental Sciences & Ecology;1715351;354581;;;;
|
||||
Social Sciences Other Topics;610266;73536;;;;
|
||||
Transportation;122943;15345;;;;
|
||||
Evolutionary Biology;208859;69632;;;;
|
||||
Social Work;119636;9546;;;;
|
||||
Fisheries;174653;30467;;;;
|
||||
Sociology;410090;25677;;;;
|
||||
Food Science & Technology;694314;109084;;;;
|
||||
Forestry;149265;33605;;;;
|
||||
Gastroenterology & Hepatology;868143;139180;;;;
|
||||
General & Internal Medicine;3003602;603320;;;;
|
||||
Genetics & Heredity;811224;258340;;;;
|
||||
Geriatrics & Gerontology;283269;53167;;;;
|
||||
Health Care Sciences & Services;451355;173053;;;;
|
||||
Hematology;773559;185719;;;;
|
||||
Immunology;1135771;323798;;;;
|
||||
Infectious Diseases;497635;212778;;;;
|
||||
Life Sciences Biomedicine Other Topics;952775;138560;;;;
|
||||
Marine & Freshwater Biology;397364;75937;;;;
|
||||
Mathematical & Computational Biology;157451;59138;;;;
|
||||
Medical Laboratory Technology;204269;23155;;;;
|
||||
Microbiology;1394937;588143;;;;
|
||||
Neurosciences & Neurology;2556499;508737;;;;
|
||||
Nursing;282475;33929;;;;
|
||||
Nutrition & Dietetics;389657;109088;;;;
|
||||
Obstetrics & Gynecology;614664;92762;;;;
|
||||
Oncology;1734168;498257;;;;
|
||||
Ophthalmology;540028;115432;;;;
|
||||
Orthopedics;384103;83121;;;;
|
||||
Otorhinolaryngology;222767;26458;;;;
|
||||
Parasitology;161861;57056;;;;
|
||||
Pathology;696224;94849;;;;
|
||||
Pediatrics;796737;133543;;;;
|
||||
Pharmacology & Pharmacy;1929649;338823;;;;
|
||||
Physiology;674877;119603;;;;
|
||||
Plant Sciences;902944;207334;;;;
|
||||
Psychiatry;1024436;161917;;;;
|
||||
Public, Environmental & Occupational Health;1088845;357248;;;;
|
||||
Radiology, Nuclear Medicine & Medical Imaging;961932;169387;;;;
|
||||
Rehabilitation;273805;44603;;;;
|
||||
Reproductive Biology;245329;63313;;;;
|
||||
Research & Experimental Medicine;1050985;276150;;;;
|
||||
Respiratory System;591292;133907;;;;
|
||||
Rheumatology;309751;82412;;;;
|
||||
Sport Sciences;324670;49193;;;;
|
||||
Substance Abuse;145560;32155;;;;
|
||||
Surgery;2057532;289477;;;;
|
||||
Toxicology;442077;71238;;;;
|
||||
Transplantation;327596;58022;;;;
|
||||
Tropical Medicine;143369;54204;;;;
|
||||
Urology & Nephrology;624122;109994;;;;
|
||||
Veterinary Sciences;668818;105675;;;;
|
||||
Virology;243503;108201;;;;
|
||||
Zoology;588363;72290;;;;
|
||||
|
Reference in New Issue
Block a user