Skip to content

Commit 62bb8c1

Browse files
committed
Commit the actual file
1 parent 08f5db5 commit 62bb8c1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/Scraper.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
public class Scraper {
1717
private static final String USERNAME = ""; // Provide your LeetCode username
1818
private static final String PASSWORD = ""; // Provide your LeetCode password
19+
public static final int QUESTIONS_PAGE_WAIT_MILLIS = 25000;
20+
public static final int LOGIN_PAGE_WAIT_MILLIS = 2000;
1921
WebDriver driver;
2022
List<String> companyURLs = new ArrayList<>();
2123

@@ -31,7 +33,7 @@ public void setup() throws InterruptedException, IOException {
3133
driver.findElement(By.xpath("// *[ @ id = 'id_login']")).sendKeys(USERNAME);
3234
driver.findElement(By.xpath("// *[ @ id = 'id_password']")).sendKeys(PASSWORD);
3335
driver.findElement(By.xpath("// *[ @ id = 'id_password']")).sendKeys(Keys.ENTER);
34-
Thread.sleep(2000); // Wait for the login to happen, then visit the problems pages
36+
Thread.sleep(LOGIN_PAGE_WAIT_MILLIS); // Wait for the login to happen, then visit the problems pages
3537
driver.get("https://leetcode.com/problemset/all/");
3638
List<WebElement> companies = driver.findElements(By.cssSelector(".mb-4.mr-3"));
3739
for (WebElement company : companies) {
@@ -48,7 +50,7 @@ private void visitCompanies(String companyURL) throws InterruptedException, IOEx
4850
String companyName = companyURL.substring(companyURL.lastIndexOf("/") + 1);
4951
System.out.println("Visiting " + companyURL);
5052
driver.get(companyURL);
51-
Thread.sleep(25000); // Wait for the page to load, for companies like Google/Amazon, it takes a lot of time
53+
Thread.sleep(QUESTIONS_PAGE_WAIT_MILLIS); // Wait for the page to load, for companies like Google/Amazon, it takes a lot of time
5254
String table = "";
5355
try {
5456
table = "<table>" + driver.findElement(By.className("table")).getAttribute("innerHTML") + "</table>";

0 commit comments

Comments
 (0)