INTRODUCTION

Well if you write a blog and share your content on variety of social media websites and forums/communities craving maximum interaction on your content, you must have at some point in time have thought  about “Man what is the best time to share my content!” early in the morning, after Lunch or at midnight.

Honestly, for me, it works after dinner around 8-9 PM IST on Facebook and Twitter. But I try them on different times just to see what might work, so in order to have that understanding for Reddit, a small idea struck me to get a trend of online users on Reddit

THE IDEA

When you visit to Reddit’s PowerShell page  you’ll find a small section at the right-hand side which shows the Number of people who had subscribed the Powershell channel and no. of users currently online as marked in the following image.1

Myself being a huge fan of Web Scraping  thought to capture this information of the number of online users from the web page on a for a small (not very small) sampling interval (every 10 mins for me) and save the data to a CSV file for a duration of a day or two to just see and understand user trend.

OK, so after inspecting the web page I found that all the data was residing in a Paragraph Tag <P> inside the HTML source code of the web page, now next step is to Web request this page and filter out our target paragraph, luckily it has a Unique class name “users-online fuzzed”  that differentiates it from other <P> Tags.

2

So, using a simple Invoke-WebRequest to the Reddit page and filtering out the HTML tag using the unique class name I got the number of online users on reddit page

fetimage

Now we need to extract the exact numbers and save them in the CSV file with a timestamp and wrap my PowerShell code in a function, like below

3

HOW TO RUN:

Schedule this script using the Task scheduler or straight away use below piece of code to run an instance of PowerShell console to start capturing the data points for you, with the TimeStamps. 

4

Like in the following image

5

I let the script run for more than two days (Tue, Wed, Thur) and it captured about 300 Data points, one every 10 minutes since I started the script.

After two days I looked into the CSV data and plotted a graph and as I expected I saw a common user behavior or you can say a trend 🙂

trend

Most of the users were online during  0300 to 0400 hours IST, now that’s some awesome geeky stuff I like 😀 . Imagine the beautiful conclusions made using such data trends if we allow it run and capture data point for a month or a year, isn’t it?

In the following image most of the peak data point are around 3 AM in the morning, IST (Indian Standard Time)

6

You can also download this CSV file using below commands on your machine and take a loot or plot a graph yourself or rather choose running the script and to capture data on your machine.
Invoke-WebRequest "https://tinyurl.com/zj4opg5" -OutFile RedditUserTrend.csv -Verbose

SCRIPT :

NOTE: 

I’m not trying to make any statements here like, the trend tell us this would be the best time for publishing your content/Questions/Information on Reddit, but who knows what might work! so we gotta keep trying 😉  I myself will try and post during the timeframe from my data analysis and see what happens, I won’t mind if am wrong.

Hoping you liked today’s geeking out and find it useful! Please share your feedback and Thank you so much for stopping by 🙂


My new book :  PowerShell Scripting Guide to Python

This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.

“Use what you know to learn what you don’t. ” also known as Associative learning.

Book follows a comparative method to jump start readers journey in Python, but who is the target audience? and who should read this book –

  • Any System Administrator who want to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
  • Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.

Python is one of the top programming languages and in fast changing IT scenarios to DevOps and Cloudto the future – Data ScienceArtificial Intelligence (AI) and Machine Learning Python is a must know.

But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell

NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!

While the book is in progress, please review it and send any feedback or error corrections at [email protected]

Optical Character Recognition

Subscribe to our mailing list

* indicates required