Reddit

Scape Post Information from Reddit’s Front Page

Goal:

Use Excel VBA to scrape from Reddit’s front page, retrieving each post in ranking order for multiple pages

For each returned search result, scrape the following:

Rank

Upvotes

Title

Outbound Link

Time Posted

Posted By

User Profile

Subreddit

Link to Sub

Number of Comments

Link to Comments

Example:

In this example, we will get all the post information on Reddit’s frontpage, from page 1 to 5.

Each page has 25 posts.

 

Worksheet Prerequisites:

Cell A1: Number of pages to gather data from (5 = scrape all data from Page 1 to Page 5)

 

Code Breakdown:

Open browser window

Browse to Reddit.com

Loop Step 1: For each post, retrieve the Rank, Upvotes, Title, Outbound Link, Time Posted, Posted By, User Profile, Subreddit, Link to Sub, Number of Comments and Link to Comments

Loop Step 2: Click “Next Page”

Repeat Loop until the result page is one page pass the inputted value in cell A1

Close browser (ie.quit; Optional)

Input appropriate headers for each column in worksheet row 1

 

Result: