Skip to content

Instantly share code, notes, and snippets.

@dhruvbaldawa
Created April 24, 2014 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhruvbaldawa/11273578 to your computer and use it in GitHub Desktop.
Save dhruvbaldawa/11273578 to your computer and use it in GitHub Desktop.
few interesting python scripts
import urllib2
import time
import os
msg_string = 'Result for %s %s declared.'
url = 'http://results.mu.ac.in/choose_nob.php?exam_id=%s&exam_year=2012&exam_month=MAY'
# some exam_id to start looking from
id_start = 2765
id_ = id_start
while True:
url_socket = urllib2.urlopen(url % id_)
temp = url_socket.read().lower()
if temp.find('no such exam!!') < 0:
# check for computer engineering
# don't trust the english grammar
if temp.find('computer') > 0:
print(msg_tring % (id_, True))
# play some music
os.system("vlc ~/01.mp3")
else:
# move onto the next exam
print(msg_string % (id_, False))
id_ += 1
else:
# wait for 5minutes
time.sleep(300)
import urllib2
import thread
from p_friends import data as friends
url = "https://faceoffmen.com/ajax/vote"
TIME_LOWER_LIMIT = 2
TIME_UPPER_LIMIT = 10
def go_fish(friends):
for friend in friends:
req = urllib2.Request(url)
#req = urllib2.Request("Page on Localhost")
req.add_header('Accept', 'application/json, text/javascript, */*; q=0.01')
# req.add_header('Accept-Encoding', 'gzip, deflate')
req.add_header('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8')
req.add_header('Cookie', 'my cookie')
req.add_header('Host', 'Page on Faceoffmen')
req.add_header('Referer', 'Page on Faceoffmen')
req.add_header('User-Agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0')
req.add_header('X-Requested-With', 'XMLHttpRequest')
s = urllib2.urlopen(req, "facebook_id=10000000000000000000&prev_facebook_id=100000184461066&next_facebook_friend=0")
print "%s(%s) voted with response as %s" % (friend['name'], friend['id'], s.read())
# time.sleep(random.randint(TIME_LOWER_LIMIT, TIME_UPPER_LIMIT))
try:
thread.start_new_thread(go_fish, (friends[:len(friends)/5],))
thread.start_new_thread(go_fish, (friends[len(friends)/5:2*len(friends)/5],))
thread.start_new_thread(go_fish, (friends[2*len(friends)/5:3*len(friends)/5],))
thread.start_new_thread(go_fish, (friends[3*len(friends)/5:4*len(friends)/5],))
thread.start_new_thread(go_fish, (friends[4*len(friends)/5:],))
except:
print "Unable to start thread"
while 1:
pass
import pickle
import time
import urllib2
import urllib
import random
import thread
from p_friends import data as friends
url = "https://www.afancan.com/thefanstation/happinesswall/api/castVotefb.php"
TIME_LOWER_LIMIT = 2
TIME_UPPER_LIMIT = 10
def go_fish(friends):
for friend in friends:
req = urllib2.Request(url)
#req = urllib2.Request("Page on Localhost")
req.add_header('Accept', '*/*')
# req.add_header('Accept-Encoding', 'gzip, deflate')
req.add_header('Content-Type','application/x-www-form-urlencoded; charset=UTF-8')
req.add_header('Cookie', 'a very long cookie')
req.add_header('Host', 'Page on Afancan')
req.add_header('Referer','http://www.afancan.com/thefanstation/happinesswall/')
req.add_header('User-Agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0')
req.add_header('X-Requested-With', 'XMLHttpRequest')
s = urllib2.urlopen(req, urllib.urlencode({'m':'xxxxxxxxxxx, 'uid':friend['id']}))
print "%s(%s) voted with response as %s" % (friend['name'], friend['id'], s.read())
# time.sleep(random.randint(TIME_LOWER_LIMIT, TIME_UPPER_LIMIT))
try:
thread.start_new_thread(go_fish, (friends[ : len(friends)/5],))
thread.start_new_thread(go_fish, (friends[len(friends)/5 : 2*len(friends)/5],))
thread.start_new_thread(go_fish, (friends[2*len(friends)/5 : 3*len(friends)/5],))
thread.start_new_thread(go_fish, (friends[3*len(friends)/5 : 4*len(friends)/5],))
thread.start_new_thread(go_fish, (friends[4*len(friends)/5 : ],))
except:
print "Unable to start thread"
while 1:
pass
@kamalx
Copy link

kamalx commented Dec 20, 2014

At first, i thought you really meant to write tring to mean something like 'alert' ;P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment