16
16
public class Scraper {
17
17
private static final String USERNAME = "" ; // Provide your LeetCode username
18
18
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 ;
19
21
WebDriver driver ;
20
22
List <String > companyURLs = new ArrayList <>();
21
23
@@ -31,7 +33,7 @@ public void setup() throws InterruptedException, IOException {
31
33
driver .findElement (By .xpath ("// *[ @ id = 'id_login']" )).sendKeys (USERNAME );
32
34
driver .findElement (By .xpath ("// *[ @ id = 'id_password']" )).sendKeys (PASSWORD );
33
35
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
35
37
driver .get ("https://leetcode.com/problemset/all/" );
36
38
List <WebElement > companies = driver .findElements (By .cssSelector (".mb-4.mr-3" ));
37
39
for (WebElement company : companies ) {
@@ -48,7 +50,7 @@ private void visitCompanies(String companyURL) throws InterruptedException, IOEx
48
50
String companyName = companyURL .substring (companyURL .lastIndexOf ("/" ) + 1 );
49
51
System .out .println ("Visiting " + companyURL );
50
52
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
52
54
String table = "" ;
53
55
try {
54
56
table = "<table>" + driver .findElement (By .className ("table" )).getAttribute ("innerHTML" ) + "</table>" ;
0 commit comments