Skip to content

Instantly share code, notes, and snippets.

@korayal
Last active December 21, 2015 18:19
Show Gist options
  • Save korayal/6346814 to your computer and use it in GitHub Desktop.
Save korayal/6346814 to your computer and use it in GitHub Desktop.
Mebmatik
import mechanize
import cookielib
import subprocess
import sched
import time
TCKimlikNo = "1234567890"
aranacakSelect = "Select$7"
kontrolSikligi = 60
player = "C:\Program Files (x86)\The KMPlayer\KMPlayer.exe"
audio_file = "C:\pastirma.wmv"
oynat = True
br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
# Browser options
br.set_handle_equiv(True)
# br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
# User-Agent (this is cheating, ok?)
br.addheaders = [('User-agent',
'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) '
'Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
#with open("list.txt", "rb") as f:
# for line in f:
s = sched.scheduler(time.time, time.sleep)
def bakalim_bakalim(sc):
br.open("http://atama.meb.gov.tr/default.aspx")
br.select_form("form1")
br.form['txtTum'] = TCKimlikNo
br.submit(name='btnSorgula')
page = br.response().read()
i = False
for links in br.links():
if aranacakSelect in str(links):
mylink = links
if oynat:
return_code = subprocess.call([player, audio_file])
print "Aciklandiiiii!!!!"
i = True
break
if not i:
sc.enter(kontrolSikligi, 1, bakalim_bakalim, (sc,))
print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ": Bekle babam bekle!"
s.enter(kontrolSikligi, 1, bakalim_bakalim, (s,))
s.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment