Skip to main content

A coding challenge webscraper for leetcode, and other websites!

Project description

leetscraper

leetscraper is a coding challenge webscraper for leetcode, and other websites!
It was created as a way to gathering coding problems to solve without having to sign up to a website or submit code to a problem checker.


Install

pip install leetscraper

Usage

Import the module and Instantiate the class. The class has some kwargs options to control the behaviour of the scraper. However, all it needs is a chromedriver path and the default values will start to scrape all problems from leetcode.com to the cwd. If you set an environment variable for "CHROMEDRIVER", Leetscraper will grab the path automatically. The most basic usage looks like this:

from leetscraper import Leetscraper

if __name__ == "__main__":
    Leetscraper()

The avaliable kwargs to control the behaviour of the scraper are:

"""
website_name: "leetcode.com", "projecteuler.net", "codechef.com" ("leetcode.com" is set if ignored)
driver_path: "path/to/chromedriver.exe" (can be ignore if environment variable CHROMEDRIVER is set)
scraped_path: "path/to/save/scraped_problems" (Current working directory is set if ignored)
scrape_limit: Integer of how many problems to scrape at a time (-1 is set if ignored, which is no limit)
auto_scrape: "True", "False" (True is set if ignored)
"""

Example of how to automatically scrape the first 50 problems from projecteuler.net to a directory called SOLVE-ME:

from leetscraper import Leetscraper

if __name__ == "__main__":
    Leetscraper(website_name="projecteuler.net", scraped_path="~/SOLVE-ME", scrape_limit=50)

You can also disable scraping problems at time of instantiation by using the kwarg auto_scrape=False. This allows you to call the class functions in different order, or one at a time. This will change how the scraper works, as its designed to look in a directory for already scraped problems to avoid duplicates. I would encourage you to look at the function docstrings if you wish to use this scraper outside of its intented automated use.


Contributing

If you would like to contribute, adding support for a new coding challenge website, or fixing current bugs is always appreciated! I would encourage you to see CONTRIBUTING.md for further details. If you would like to report bugs or suggest websites to support, please add a card to Issues.


Licence

This project uses the GPL-2.0 License, As generally speaking, I want you to be able to do whatever you want with this project, But still have the ability to add your changes to this codebase should you make improvements or extend support. For further details on what this licence allows, please see LICENSE.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leetscraper-1.0.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leetscraper-1.0.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file leetscraper-1.0.0.tar.gz.

File metadata

  • Download URL: leetscraper-1.0.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for leetscraper-1.0.0.tar.gz
Algorithm Hash digest
SHA256 74a539595df8fac2721fe8e4e263f70054673b9bcae3478589301390a7ae9959
MD5 8d2153f4c2891e885b1081b22543543a
BLAKE2b-256 fb9e038b7e560818e1df3e0bb217e5e1e748ab1fdb5c70fcd12b465ca7108e14

See more details on using hashes here.

File details

Details for the file leetscraper-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: leetscraper-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for leetscraper-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f270bfb4822d4df2e5572d645f25a64bb379633cf209323f04325626c56e64d1
MD5 ffa8ad5efbd2b21b44e7e110c79715e8
BLAKE2b-256 ef5be9ec738b0ab2e565816f7008de656605892f42fa349b25f58e81e54d1c0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page