-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolved conflict in .gitignore and merged pre-release changes into main.#
- Loading branch information
Showing
26 changed files
with
1,292 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>Projects</groupId> | ||
<artifactId>Scrapers</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>Scrapers</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>22</maven.compiler.source> <!-- Ensure this matches your Java version --> | ||
<maven.compiler.target>22</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- JUnit dependency for testing --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Selenium dependency --> | ||
<dependency> | ||
<groupId>org.seleniumhq.selenium</groupId> | ||
<artifactId>selenium-java</artifactId> | ||
<version>4.23.1</version> | ||
</dependency> | ||
|
||
<!-- Gson dependency --> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.11.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
|
||
<!-- Maven Assembly Plugin to create a runnable JAR with dependencies --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>3.3.0</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<!-- Replace with the fully qualified name of your main class --> | ||
<mainClass>Projects.StartGUI</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
18 changes: 18 additions & 0 deletions
18
src/Projects/CourtScraper/DataManagement/CSV/CSVDownloadedAppend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package CourtScraper.DataManagement.CSV; | ||
|
||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
|
||
|
||
public class CSVDownloadedAppend { | ||
|
||
public static void appendToDownloaded(String row) throws IOException { | ||
FileWriter csvFile = new FileWriter(CourtScraper.Helpers.CheckIfRetrieved.downloadedFilePath, true); | ||
|
||
csvFile.append("\n"); | ||
csvFile.append(row); | ||
|
||
csvFile.flush(); | ||
csvFile.close(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Projects/CourtScraper/DataManagement/CSV/CSVManagement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package CourtScraper.DataManagement.CSV; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
public class CSVManagement { | ||
|
||
//path to be used for accessing temp file | ||
|
||
|
||
public static void deleteLine(String tempFilePath, String tempFolderPath, String line) throws IOException { | ||
File newTempFile = new File(tempFolderPath + "\\temp2temp.csv"); | ||
newTempFile.createNewFile(); | ||
File oldTempFile = new File(tempFilePath); | ||
|
||
FileWriter writer = new FileWriter(tempFolderPath + "\\temp2temp.csv"); | ||
|
||
List<String> rows = Files.readAllLines(Path.of(tempFilePath)); | ||
|
||
for (String row : rows) { | ||
if (row.equals(line)) { | ||
continue; | ||
} | ||
writer.write(row + "\n"); | ||
} | ||
|
||
writer.flush(); | ||
writer.close(); | ||
|
||
oldTempFile.delete(); | ||
newTempFile.renameTo(oldTempFile); | ||
|
||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/Projects/CourtScraper/DataManagement/CSV/CSVSearchAppendTemp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package CourtScraper.DataManagement.CSV; | ||
|
||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import static CourtScraper.Flows.Courtlink.CourtlinkSearchConfig.CourtlinkSearchConfigMain.processedInputs; | ||
import static CourtScraper.Setups.GUI.MainPanelElements.MainComboBoxes.selectedCounty; | ||
import static CourtScraper.Setups.GUI.MainPanelElements.MainComboBoxes.selectedState; | ||
|
||
|
||
public class CSVSearchAppendTemp { | ||
|
||
public static String tempFilePath = "C:\\Users\\" + System.getenv("USERNAME") + "\\Desktop\\Courtlink Scraper\\States\\" + selectedState + "\\" + selectedCounty + "\\temp.csv"; | ||
|
||
//declarations of current date and time | ||
private static SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); | ||
private Date date = new Date(); | ||
|
||
public void courtLinkAppendToTemp(List<String> toBeAppended) throws IOException { | ||
|
||
String appendableString = ""; | ||
|
||
FileWriter csvFile = new FileWriter(tempFilePath, true); | ||
|
||
//adds case number and date of case filed from the courtlink site | ||
for (String element : toBeAppended) { | ||
appendableString += element.substring(1) + ","; | ||
} | ||
|
||
//adds keywords used in search | ||
appendableString += processedInputs[0] + ","; | ||
//adds attorney terms used in search | ||
appendableString += processedInputs[1] + ","; | ||
//adds current date and time from which the document was grabbed from | ||
appendableString += dateFormat.format(date) + ","; | ||
//adds selected state | ||
appendableString += selectedState + ","; | ||
//added selected county | ||
appendableString += selectedCounty + ","; | ||
//adds documents selected | ||
appendableString += "" + ","; | ||
|
||
|
||
csvFile.append("\n"); | ||
csvFile.append(appendableString.substring(0, appendableString.length() - 1)); | ||
|
||
csvFile.flush(); | ||
csvFile.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package CourtScraper; | ||
|
||
import CourtScraper.Flows.Courtlink.CourtlinkMain; | ||
import CourtScraper.Setups.Browser.Firefox; | ||
|
||
import java.io.IOException; | ||
|
||
|
||
|
||
public class FlowStart { | ||
|
||
public static void StartMainFlowButton() throws IOException, InterruptedException { | ||
|
||
new Firefox().FirefoxLaunch(); | ||
new CourtlinkMain().CourtlinkFlow(); | ||
|
||
//closes all open tabs | ||
CourtScraper.Helpers.TabManagement.closeAllTabs(); | ||
|
||
CourtScraper.Flows.States.StateParser.stateRetrievalFlow(); | ||
|
||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/Projects/CourtScraper/Flows/Courtlink/CourtlinkMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package CourtScraper.Flows.Courtlink; | ||
|
||
import CourtScraper.Flows.Courtlink.CourtlinkScraper.CourtlinkScrapeMain; | ||
import CourtScraper.Helpers.ConfigGrabbers; | ||
import CourtScraper.StartGUI; | ||
import org.openqa.selenium.By; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
|
||
|
||
import static CourtScraper.Flows.Courtlink.CourtlinkSearchConfig.CourtlinkSearchConfigMain.courtLinkTermInputs; | ||
|
||
public class CourtlinkMain { | ||
|
||
public void CourtlinkFlow() throws IOException, InterruptedException { | ||
//Login process | ||
courtLinkLogin(); | ||
|
||
Thread.sleep(1000); | ||
|
||
//inputs terms/dates into input boxes | ||
courtLinkTermInputs(); | ||
|
||
Thread.sleep(1000); | ||
|
||
//scrapes courtlink for casenumbers | ||
CourtlinkScrapeMain.courtLinkScrape(); | ||
|
||
|
||
} | ||
|
||
|
||
public static void courtLinkLogin() throws FileNotFoundException, InterruptedException { | ||
StartGUI.driver.get("https://signin.lexisnexis.com/lnaccess/app/signin?back=https%3A%2F%2Fadvance.lexis.com%3A443%2Fcourtlinkhome&aci=la"); | ||
String[] credentials = new ConfigGrabbers().loginGrabber("courtlink"); | ||
|
||
StartGUI.driver.findElement(By.xpath("//*[@id=\"userid\"]")).sendKeys(credentials[0]); | ||
StartGUI.driver.findElement(By.xpath("//*[@id=\"signInSbmtBtn\"]")).click(); | ||
Thread.sleep(1500); | ||
StartGUI.driver.findElement(By.xpath("//*[@id=\"password\"]")).sendKeys(credentials[1]); | ||
StartGUI.driver.findElement(By.xpath("//*[@id=\"signInSbmtBtn\"]")).click(); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/Projects/CourtScraper/Flows/Courtlink/CourtlinkScraper/CourtlinkScrapeMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package CourtScraper.Flows.Courtlink.CourtlinkScraper; | ||
|
||
import CourtScraper.DataManagement.CSV.CSVSearchAppendTemp; | ||
import CourtScraper.Flows.Courtlink.CourtlinkMain; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
import java.io.IOException; | ||
import java.time.Duration; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static CourtScraper.StartGUI.driver; | ||
|
||
|
||
public class CourtlinkScrapeMain extends CourtlinkMain { | ||
|
||
private static WebDriverWait wait; | ||
private static int numCases = Integer.valueOf(driver.findElement(By.xpath("/html/body/main/div/main/div[2]/div/div[1]/div/div[1]/ul/li[1]")).getAttribute("data-actualresultscount")); | ||
|
||
public static void courtLinkScrape() throws IOException, InterruptedException { | ||
wait = new WebDriverWait(driver, Duration.ofSeconds(10)); | ||
Thread.sleep(500); | ||
System.out.println(numCases); | ||
driver.findElement(By.xpath("//*[@id=\"title_sr0\"]")).click(); | ||
//waits until first page is loaded | ||
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"Header\"]"))); | ||
|
||
//Grabs Case Info | ||
for (int i = numCases-1; !(i == 0); i--) { | ||
//grabs info on page | ||
new CourtlinkScrapeMain().grabCaseInfo(); | ||
Thread.sleep(2000); | ||
|
||
//grabs url for later next page loaded check | ||
String url = driver.getCurrentUrl(); | ||
|
||
//clicks next button to move on to the next case | ||
driver.findElement(By.xpath("/html/body/main/div/main/div/form/div[1]/div[1]/ul[3]/li/button[2]/span[1]")).click(); | ||
|
||
//ends if on last page to prevent stoppage and grabs last case before stopping | ||
if (i==1) { | ||
new CourtlinkScrapeMain().grabCaseInfo(); | ||
Thread.sleep(2000); | ||
break; | ||
} | ||
//waits until next page loaded | ||
wait.until(ExpectedConditions.not(ExpectedConditions.urlToBe(url))); | ||
Thread.sleep(500); | ||
|
||
|
||
} | ||
} | ||
|
||
public void grabCaseInfo() throws IOException { | ||
List<String> toBeAppended = new ArrayList<>(); | ||
|
||
//inner text retrieves text not html from the inside and splits it | ||
|
||
String caseInfo = driver.findElement(By.xpath("//*[@id=\"Header\"]")).getAttribute("innerText"); | ||
String[] info = caseInfo.split("\n"); | ||
|
||
//adds the case number and date filed in a loop | ||
for (int i = 1; i<3; i++) { | ||
String[] elements = info[i].split(":", 2); | ||
toBeAppended.add(elements[1].trim()); | ||
} | ||
//adds them to temporary csv file | ||
new CSVSearchAppendTemp().courtLinkAppendToTemp(toBeAppended); | ||
|
||
} | ||
} |
Oops, something went wrong.