Compare commits

1 Commits
Author SHA1 Message Date
arzani abb3833ebe added dev version 2021-03-23 09:33:13 +01:00
2 changed files with 84 additions and 150 deletions
@@ -20,8 +20,8 @@ public class WebOfScienceCrawler {
private static final int MARKED_LIST_MAX = 50000; private static final int MARKED_LIST_MAX = 50000;
private static final int WOS_RECORD_LIMIT = 100000; private static final int WOS_RECORD_LIMIT = 100000;
private static final int RECORDS_MAX = 500; private static final int RECORDS_MAX = 500;
private static final int PUB_YEAR_START = 2010; private static final int PUB_YEAR_START = 2011;
private static final int PUB_YEAR_END = 2020; private static final int PUB_YEAR_END = 2021;
private static final String PUB_YEAR_RESEARCH_SPAN = "(1900-2020)"; private static final String PUB_YEAR_RESEARCH_SPAN = "(1900-2020)";
private final boolean statisticsFlag = false; 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"); System.setProperty("webdriver.gecko.driver", "src/main/java/de/nes/guide/wos/util/geckodriver.exe");
profile = new FirefoxProfile(); profile = new FirefoxProfile();
options = new FirefoxOptions(); 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); profile.setPreference("browser.helperApps.alwaysAsk.force", false);
options.setProfile(profile); options.setProfile(profile);
options.setHeadless(true);
driver = new FirefoxDriver(options); driver = new FirefoxDriver(options);
EventFiringWebDriver eventDriver = new EventFiringWebDriver(driver); EventFiringWebDriver eventDriver = new EventFiringWebDriver(driver);
eventDriver.register(new CostomDriverListener()); eventDriver.register(new CostomDriverListener());
@@ -109,7 +112,7 @@ public class WebOfScienceCrawler {
if (driver.findElements(By.xpath(element)).size() > 0) { if (driver.findElements(By.xpath(element)).size() > 0) {
driver.findElement(By.xpath(element)).click(); driver.findElement(By.xpath(element)).click();
} else { } else {
checkAndRedirectPage(driver); //checkAndRedirectPage(driver);
} }
} else { } else {
driver.findElement(By.xpath(element)).click(); driver.findElement(By.xpath(element)).click();
@@ -125,7 +128,7 @@ public class WebOfScienceCrawler {
if (driver.findElements(By.cssSelector(element)).size() > 0) { if (driver.findElements(By.cssSelector(element)).size() > 0) {
driver.findElement(By.cssSelector(element)).click(); driver.findElement(By.cssSelector(element)).click();
} else { } else {
checkAndRedirectPage(driver); //checkAndRedirectPage(driver);
} }
} else { } else {
driver.findElement(By.cssSelector(element)).click(); driver.findElement(By.cssSelector(element)).click();
@@ -148,7 +151,9 @@ public class WebOfScienceCrawler {
driver.navigate().to(WOS_URL); driver.navigate().to(WOS_URL);
checkWOSLogin(driver); checkWOSLogin(driver);
changeToAdvancedSearchTab(driver); changeToAdvancedSearchTab(driver);
performAdvancedSearch(driver); //performAdvancedSearch(driver);
performAdvancedSearchforDUE(driver);
//performAdvancedSearchComputerScience(driver);
terminateDriver(driver); terminateDriver(driver);
fileWriter.cleanUpFileWriter(); fileWriter.cleanUpFileWriter();
} catch (Exception e) { } 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 * This method quites the firefox driver
*/ */
@@ -170,16 +186,21 @@ public class WebOfScienceCrawler {
* */ * */
private void selectResultsforMarkedList(FirefoxDriver driver) { private void selectResultsforMarkedList(FirefoxDriver driver) {
int numberOfRecords = 0; int numberOfRecords = 0;
if (performingExport) { numberOfRecords = Integer
numberOfRecords = Integer.parseInt(driver.findElement(By.xpath("//*[@id=\"hitCount.top\"]")).getText().replace(",", "")) - (startingRecord50ks - 1); .parseInt(driver.findElement(By.xpath("//*[@id=\"hitCount.top\"]")).getText().replace(",", ""));
} else {
numberOfRecords = Integer.parseInt(driver.findElement(By.xpath("//*[@id=\"hitCount.top\"]")).getText().replace(",", ""));
}
System.out.println("Total number of records for this field: " + numberOfRecords); System.out.println("Total number of records for this field: " + numberOfRecords);
int quotient = numberOfRecords / MARKED_LIST_MAX; int quotient = numberOfRecords / MARKED_LIST_MAX;
int remainder = numberOfRecords % MARKED_LIST_MAX; int remainder = numberOfRecords % MARKED_LIST_MAX;
if (numberOfRecords > WOS_RECORD_LIMIT) System.out.println(quotient + "/" + remainder);
numberOfRecords = WOS_RECORD_LIMIT; 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) { if (numberOfRecords <= MARKED_LIST_MAX) {
performMarkedList(driver, startingRecord50ks, (startingRecord50ks + numberOfRecords - 1)); performMarkedList(driver, startingRecord50ks, (startingRecord50ks + numberOfRecords - 1));
} else { } else {
@@ -190,7 +211,7 @@ public class WebOfScienceCrawler {
} }
if (remainder != 0) { if (remainder != 0) {
startingRecord500s = 1; 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) { private void performMarkedList(FirefoxDriver driver, int startingRecord, int numberOfRecords) {
System.out.println(driver.getTitle()); System.out.println(driver.getTitle());
simulateUserWait(15); simulateUserWait(10);
if(sortByCitedOnce){ 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(); 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; sortByCitedOnce = false;
@@ -285,7 +306,7 @@ public class WebOfScienceCrawler {
* */ * */
private void performExport(FirefoxDriver driver, int startingRecord, int endingRecord) { private void performExport(FirefoxDriver driver, int startingRecord, int endingRecord) {
System.out.println(driver.getTitle()); 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); simulateUserWait(5);
checkElementAvailabilityPerXpath(driver, "//*[@id=\"record_select_type_range\"]"); checkElementAvailabilityPerXpath(driver, "//*[@id=\"record_select_type_range\"]");
WebElement selectAllCharacteristicsCheckbox = driver.findElement(By.cssSelector("#value\\(select_All\\)")); WebElement selectAllCharacteristicsCheckbox = driver.findElement(By.cssSelector("#value\\(select_All\\)"));
@@ -304,6 +325,27 @@ public class WebOfScienceCrawler {
simulateUserWait(3); simulateUserWait(3);
toRecord.sendKeys(Integer.toString(endingRecord)); toRecord.sendKeys(Integer.toString(endingRecord));
simulateUserWait(3); 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) { if (driver.findElements(By.id("exportTypeName")).size() > 0) {
String buttonText = driver.findElement(By.id("exportTypeName")).getText().toLowerCase(); String buttonText = driver.findElement(By.id("exportTypeName")).getText().toLowerCase();
if (!buttonText.contains("excel")) { if (!buttonText.contains("excel")) {
@@ -345,6 +387,17 @@ public class WebOfScienceCrawler {
deleteHitsButton.click(); 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 * 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\"]")); WebElement advancedSearchFormButton = driver.findElement(By.xpath("//*[@id=\"search-button\"]"));
advancedTextArea.sendKeys(Keys.TAB); advancedTextArea.sendKeys(Keys.TAB);
advancedTextArea.clear(); advancedTextArea.clear();
String query = buildAdvancedQuery(field); //String query = buildAdvancedQuery(field);
String query = buildAdvancedQueryforDUE();
simulateUserWait(3); simulateUserWait(3);
advancedTextArea.sendKeys(query); 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 * 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 * It also writes this info in a CSV data for later analysis
-133
View File
@@ -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;;;;
1 Field records OpenAccess SUM
2 Architecture 157184 9772 100090806
3 Agriculture 1258250 268126
4 Astronomy & Astrophysics 704392 205797 133,454408 Number of days needed
5 Archaeology 135733 9936
6 Acoustics 197357 31864
7 Art 331346 10018
8 Allergy 181079 20917
9 Chemistry 6557397 602901
10 Area Studies 233337 15456
11 Automation & Control Systems 241646 17491
12 Arts & Humanities Other Topics 762735 47240
13 Anatomy & Morphology 145980 16638
14 Crystallography 334669 69155
15 Biomedical Social Sciences 135483 27443
16 Computer Science 1454122 219190
17 Asian Studies 126883 5946
18 Anesthesiology 276793 61569
19 Electrochemistry 322667 21693
20 Business & Economics 1608648 190585
21 Construction & Building Technology 179249 16070
22 Classics 110952 3321
23 Anthropology 303895 25726
24 Geochemistry & Geophysics 400153 62025
25 Communication 161620 23340
26 Energy & Fuels 627276 65401
27 Audiology & Speech-Language Pathology 104950 20390
28 Geology 714303 133921
29 Engineering 5759153 583577
30 Film, Radio & Television 156577 3472
31 Behavioral Sciences 240493 43763
32 Mathematics 1751209 400913
33 Imaging Science & Photographic Technology 100530 9554
34 History 1199348 76956
35 Biochemistry & Molecular Biology 3073455 811653
36 Meteorology & Atmospheric Sciences 344571 135819
37 Information Science & Library Science 444958 35208
38 History & Philosophy of Science 149771 18349
39 Biodiversity & Conservation 130093 29642
40 Mineralogy 103740 10164
41 Instruments & Instrumentation 556652 65275
42 Literature 1388359 37827
43 Biophysics 712286 147327
44 Education & Educational Research 858361 122709
45 Materials Science 2961158 333238
46 Music 364074 5754
47 Biotechnology & Applied Microbiology 757383 256049
48 Oceanography 218548 63059
49 Mechanics 536433 43851
50 Philosophy 483597 48796
51 Cardiovascular System & Cardiology 1666052 378169
52 Optics 718165 115827
53 Metallurgy & Metallurgical Engineering 654820 63696
54 Religion 384368 24365
55 Cell Biology 1391609 426015
56 Physical Geography 127624 23238
57 Geography 383771 45467
58 Theater 101539 2285
59 Physics 4839924 468020
60 Government & Law 1063190 57405
61 Nuclear Science & Technology 449361 22319
62 Dentistry, Oral Surgery & Medicine 430892 48663
63 Polymer Science 589737 52366
64 International Relations 251637 15259
65 Operations Research & Management Science 238725 18530
66 Dermatology 483880 54901
67 Thermodynamics 315692 25133
68 Linguistics 398325 40606
69 Developmental Biology 184639 52093
70 Water Resources 334249 54790
71 Emergency Medicine 119251 22943
72 Psychology 1883657 236522
73 Science & Technology Other Topics 2615136 884902
74 Endocrinology & Metabolism 920979 186870
75 Public Administration 204000 13681
76 Spectroscopy 251668 16414
77 Entomology 265441 35304
78 Social Issues 172513 13339
79 Telecommunications 455745 86332
80 Environmental Sciences & Ecology 1715351 354581
81 Social Sciences Other Topics 610266 73536
82 Transportation 122943 15345
83 Evolutionary Biology 208859 69632
84 Social Work 119636 9546
85 Fisheries 174653 30467
86 Sociology 410090 25677
87 Food Science & Technology 694314 109084
88 Forestry 149265 33605
89 Gastroenterology & Hepatology 868143 139180
90 General & Internal Medicine 3003602 603320
91 Genetics & Heredity 811224 258340
92 Geriatrics & Gerontology 283269 53167
93 Health Care Sciences & Services 451355 173053
94 Hematology 773559 185719
95 Immunology 1135771 323798
96 Infectious Diseases 497635 212778
97 Life Sciences Biomedicine Other Topics 952775 138560
98 Marine & Freshwater Biology 397364 75937
99 Mathematical & Computational Biology 157451 59138
100 Medical Laboratory Technology 204269 23155
101 Microbiology 1394937 588143
102 Neurosciences & Neurology 2556499 508737
103 Nursing 282475 33929
104 Nutrition & Dietetics 389657 109088
105 Obstetrics & Gynecology 614664 92762
106 Oncology 1734168 498257
107 Ophthalmology 540028 115432
108 Orthopedics 384103 83121
109 Otorhinolaryngology 222767 26458
110 Parasitology 161861 57056
111 Pathology 696224 94849
112 Pediatrics 796737 133543
113 Pharmacology & Pharmacy 1929649 338823
114 Physiology 674877 119603
115 Plant Sciences 902944 207334
116 Psychiatry 1024436 161917
117 Public, Environmental & Occupational Health 1088845 357248
118 Radiology, Nuclear Medicine & Medical Imaging 961932 169387
119 Rehabilitation 273805 44603
120 Reproductive Biology 245329 63313
121 Research & Experimental Medicine 1050985 276150
122 Respiratory System 591292 133907
123 Rheumatology 309751 82412
124 Sport Sciences 324670 49193
125 Substance Abuse 145560 32155
126 Surgery 2057532 289477
127 Toxicology 442077 71238
128 Transplantation 327596 58022
129 Tropical Medicine 143369 54204
130 Urology & Nephrology 624122 109994
131 Veterinary Sciences 668818 105675
132 Virology 243503 108201
133 Zoology 588363 72290