Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Omegle Online
- # Saves the number of users on omegle every hour.
- # Coded by LKP
- # Respect to Don J
- import os
- import ast
- import sqlite3
- import requests
- import urllib2
- import time
- from datetime import date
- class omegle(object):
- website = "http://omegle.com/status"
- omg_time = time.strftime("%H:%M")
- omg_date = [date.today().day,date.today().month,date.today().year]
- def interface(self):
- # Basic Interface for a user to use, it works off of numbers so type in the relevant number.
- os.system("cls")
- print "\n Welcome to Omegle User Counter!\n Would you like to do?\n 1) Start\n 2) Setup\n 3) Exit"
- choice = raw_input(" > ")
- if choice == "1":
- os.system("cls")
- print "\n Starting now!"
- self.start()
- elif choice == "2":
- os.system("cls")
- print "\n Starting setup now!"
- omegle.setup()
- elif choice == "3":
- os.system("cls")
- print "\n Exiting now!"
- else:
- os.system("cls")
- print "\n Unrecognised command!"
- time.sleep(2)
- omegle.interface()
- def start(self):
- os.system("cls")
- print "\n Grabbing users online now from",self.website
- statusurl = urllib2.urlopen("http://www.omegle.com/status") # Code thanks to Don J
- statustext = statusurl.read() # Code thanks to Don J
- status = ast.literal_eval(statustext) # Code thanks to Don J
- count = status["count"] # Code thanks to Don J
- print "\n Saving to database now!"
- connect = sqlite3.connect('Omegle.db')
- omegle = connect.cursor()
- omegle.execute("INSERT INTO user_count VALUES (?, ?, ?)",(count, str(self.omg_date[0])+"-"+str(self.omg_date[1])+"-"+str(self.omg_date[2]), str(self.omg_time)))
- connect.commit()
- os.system("cls")
- print "\n Waiting one hour!"
- time.sleep(3600)
- self.start()
- def setup(self):
- # Checks if the database exists, I could have used Try but they don't really make much difference.
- # Creates the Database to write the online users to.
- if os.path.exists("Omegle.db") == True:
- os.system("cls")
- print "\n The database already exists!\n Returning to interface!"
- time.sleep(2)
- self.interface()
- else:
- os.system("cls")
- print "\n Creating the database!"
- connect = sqlite3.connect('Omegle.db')
- omegle = connect.cursor()
- print "\n Creating the table for the users and time!"
- omegle.execute("""CREATE TABLE user_count(users,date,time)""")
- print "\n Database Creation complete!\n returning to interface!"
- time.sleep(2)
- self.interface()
- omegle = omegle()
- omegle.interface()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement