Skip to content
baymaxing edited this page Nov 3, 2018 · 8 revisions

Welcome to leetcode table converter wiki

This project is written under spring boot framework with maven support. It also incorporates some of the selenium and Jsoup features to simulate a few actions such as login, navigating to target url,etc. It is intended to convert html table on specified leetcode question web page to an excel sheet with style.

For eg: the target url is https://leetcode.com/company/microsoft/

leetcode microsoft questions

As you can see, leetcode question web page displays a html table which contains all the microsoft algorithm problems with #, title, acceptance, and etc. The application is programmed to convert this html table to an excel sheet with the following format.

excel format

From the excel sheet, you will have similar column content that was transformed from the web page. The heart symbol ❤ marks the questions that have been completed before. Each question title contains hyper links that could be navigated back to the problem.

It would be easier to manipulate the question data using the built-in functionality of microsoft excel sheet.

How to use the application:

Open application.properties, you should be able to see content as below:

#file location

  • html.input.file=C:\\Users\\baymaxing\\Downloads\\Microsoft - LeetCode.html
  • excel.output.file=C:\\Users\\baymaxing\\excel\\myquestions_

#leetcode info

  • leetcode.username=<your_leetcode_username>
  • leetcode.password=<your_leetcode_password>

#leetcode links

#chrome driver location

  • webdriver.chrome.driver=${user.dir}/libs/chromedriver.exe

#page wait time

  • default.timeout.seconds=30`
  • default.wait.miliseconds=5000`

#css selector for sort by column

  • sortby.cssselector.difficulty=th.reactable-th-difficulty
  • sortby.cssselector.acceptance=th.reactable-th-acceptance
  • sortby.cssselector.title=th.reactable-th-title
  • sortby.cssselector.id=th.reactable-th-id
  • sortBy.column=difficulty

Required Fields:

#leetcode info

  • leetcode.username=<your_leetcode_username>
  • leetcode.password=<your_leetcode_password>

#leetcode links

  • target.link=<your_target_link_on_leetcode_that_contains_question_table>

#file location

  • excel.output.file=<your_desired_location_for_excelfile_output>\\myquestions_

Optional Fields:

sortBy.column:

#css selector for sort by column

  • sortBy.column=difficulty

If you would like to pre order the content by other column than difficulty. You could update this field as below:

  • sortBy.column=id OR
  • sortBy.column=title OR
  • sortBy.column=acceptance

html.input.file

In the application, it is by default calling getHtmlTableWithJsoup() in main class ExporttoexcelApplication to login to leetcode and navigate to the url and parse html then convert to excel. You could modify the source code to use another function getHtmlTableFromLocalhtml() which takes a local html file if you have already download the html from leetcode webpage.

converterApp.converter.getHtmlTableWithJsoup();

=>

converterApp.converter.getHtmlTableFromLocalhtml();

Update the application.properties file with the location of the downloaded html file:

html.input.file=C:\\Users\\baymaxing\\Downloads\\Microsoft - LeetCode.html


Happy Coding!