Skip to content

Instantly share code, notes, and snippets.

@SmartManoj
Created June 20, 2022 23:59
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 SmartManoj/d9ea02ee7c01aaf3977515233ed87ba8 to your computer and use it in GitHub Desktop.
Save SmartManoj/d9ea02ee7c01aaf3977515233ed87ba8 to your computer and use it in GitHub Desktop.
print(34)
print(34)
import requests
from threading import Thread
from bs4 import BeautifulSoup
from pyperclip import copy
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36",
}
b = 'http://tnresults.nic.in/'
s = requests.session()
import webbrowser
from datetime import timedelta, date
import os
from time import sleep
r2 = lambda x, y=None: round(x + 1e-15, y)
c = 0
from collections import namedtuple
def ks(x='', y=''):
print(x, y)
global c
data = {'regno': rno, 'dob': dob, "B1": "Get Marks"}
if y:
z = y.strftime("%d/%m/%Y")
data['dob'] = z
# data['regno']=x
cache = 1
if cache:
res = namedtuple('res', ['text', 'status_code'])
req = res(text=open('res.html').read(), status_code=200)
else:
while True:
req = s.post(url, data=data)
if not req.ok or req.text == 'Some Issue in connection, Pl check':
print(req.ok)
sleep(1)
else:
break
cb = 0
if 'Please check your Registration Number and DOB' not in req.text:
print(req.text, req.status_code) # exit()
print(req.text, file=open('res.html', 'w')) # exit()
if y:
print('Found', z)
if yr == 10 and 0:
os._exit(1)
z = ('```\n')
soup = BeautifulSoup(req.text, 'lxml')
z += '{}\t{}\nDOB: {}\n'.format((repr(soup.select('table')
[1].select('tr')[0].text).split(r'\xa0\xa0\xa0')[0][3:]), rno, dob)
for k, i in enumerate((soup.select('table')[1]).select('tr')[2:]):
j = i.select('td')
_ = j[-1 - (yr == 12)].text.split()[-1]
z += ("{:20}".format(repr(j[0].text).replace(r'\xa0', '')) +
' ' + repr(_).replace(r'\xa0', '')) + '\n'
if k in [2, 3]:
cb += int(_) / 4
elif k in [5]:
cb1 = cb + int(_) / 2
elif k in [4]:
cb2 = cb + int(_) / 2
elif k == 6:
tot = int(_)
if 'PHYSICS' in z:
z += ("{:20}".format("'Eng CutOFF'") + ' ' + str(r2(cb1, 2))) + '\n'
if 'PHYSICS' in z and 'BIOLOGY' in z:
z += ("{:20}".format("'Med CutOFF'") + ' ' + str(r2(cb2, 2))) + '\n'
z += f"{'Percentage':20} {(tot/600):.2%}"
z += ('\n```')
print(z, flush=True)
copy(z)
os._exit(1)
else:
c += 1
if y:
print(c, z)
else:
print('Wrong')
yr = 12
if yr == 12:
url = f"{b}acpter.asp"
headers["Referer"] = f"{b}acpter.htm"
rno = 5295645 # random
dob = '27/09/2005'
elif yr == 11:
url = f"{b}fshrs.asp"
headers["Referer"] = f"{b}fshsc.htm"
rno = 3304428
dob = '27/03/2002' # random
elif yr == 10:
# need verify
url = f"{b}arcxrs.asp"
headers["Referer"] = f"{b}arcxrs.htm"
rno = 1322075 # random
dob = '19/01/2007'
s.headers.update(headers)
if 1:
ks()
exit()
if yr == 10:
x = 3
if yr == 11:
x = 2
if yr == 12:
x = 1
def daterange(x):
start_date = date(x, 1, 1)
end_date = date(x + 1, 1, 1)
for n in range(int((end_date - start_date).days)):
yield start_date + timedelta(n)
for y in (x,):
tt = [Thread(target=ks, args=(k, single_date,))
for k, single_date in enumerate(daterange(2004 + y))]
for t in tt:
t.start()
for t in tt:
t.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment