Skip to content

BrotherIndeed/leetcode_scraper_and_pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leetcode_scraper_and_pdf

A leetcode scraper to compile all questions in leetcode free tier to text file. pdf also available.

if new questions get added

Open google chrome, navigate to leetcode problems page click on inspect, navigate to dev console and paste the commands below. Copy question links and paste in text file named question_links.txt go to next page and repeat till you have all the questions links. Put the python script and question links file in same folder. run and wait to compile to text file, the convert to pdf online.

var x = document.querySelectorAll("a");
var myarray = []
for (var i=0; i<x.length; i++){
  if(x[i].getAttribute('href').indexOf('problem') > -1 && x[i].getAttribute('href').indexOf('solution') == -1 )
  {
  var cleanlink = x[i].href;
  myarray.push([cleanlink]);
  }
};
function make_table() {
    var table = '<table><thead><th>Links</th></thead><tbody>';
   for (var i=0; i<myarray.length; i++) {
            table += '<tr><td>'+ myarray[i][0] ;
    };

    var w = window.open("");
w.document.write(table);
}
make_table()

About

A leetcode scraper to compile all questions in leetcode free tier to text file, pdf also available. if new questions get added, run again to get new questions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages