Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4a4c88f

Browse files
Commit the actual file
1 parent df3d3c7 commit 4a4c88f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎src/main/java/Scraper.java

Lines changed: 4 additions & 2 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /