Giter Club home page Giter Club logo

web-scraping-reddit's Introduction

Web Scraping Reddit

Web scraping /r/MachineLearning with BeautifulSoup and Selenium, without using the Reddit API, since you mostly web scrape when an API is not available -- or just when it's easier.

If you found this repository useful, consider giving it a star, such that you easily can find it again.

Features

  • App can scrape most of the available data, as can be seen from the database diagram.
  • Choose subreddit and filter
  • Control approximately how many posts to collect
  • Headless browser. Run this app in the background and do other work in the mean time.

Database Diagram

Future improvements

This app is not robust (enough). There are extremely many edge cases in web scraping, and this would be something to improve upon in the future.

Pull requests are welcome.

  • Get rid of as many varchars in comment table as possible; use int for higher quality data.
  • Make app robust
  • Download driver automatically
  • Add more browsers for running this project (Firefox first)
  • Give categories and flairs their own table, right now they are just concatenated into a string.

Install

To run this project, you need to have the following (besides Python 3+):

  1. Chrome browser installed on your computer.
  2. Paste this into your address bar in Chrome chrome://settings/help. Download the corresponding chromedriver version here.
  3. Place the chromerdriver in the core folder of this project.
  4. Install the packages from requirements.txt file by pip install -r requirements.txt

After these steps, you can run scraper.py to scrape and store the reddit data in an sqlite database. It's recommended to download DB Browser For SQLite to browse the database. If you want to pull out the data, you should use make_dataset.py. For a last demonstration, we can run a Machine Learning project using mlproj.py.

Note: If your Chrome browser automatically updates to a new version, the chromedriver that you downloaded will almost surely not work, after an automatic update.

web-scraping-reddit's People

Contributors

casper-hansen avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

web-scraping-reddit's Issues

[Question] What are the use cases ?

What are the use cases of this project ? I am new to the web scraping and i want to explore different areas ( how can we use it to benefit businesses ) and i am curious what can we get if we scrape reddit or quora ?

ValueError

Having trouble tracking down why this error is occurring. I've tried different subreddits and I get the same error. Any help?

File "scraper.py", line 34, in
BSS.data = SelScraper.reddit_data_to_dict(script_data = script_data)
File "/Users/.../selenium_scraper.py", line 114, in reddit_data_to_dict
first_index = data.index('{')
ValueError: substring not found

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.