sameerbanchhor-work's picture
download
raw
4.86 kB
import requests
from bs4 import BeautifulSoup
import json
AJAX_URL = "https://durg.ucanapply.com/get-result-details"
REGULAR_BATCHES_FILE = "regular_private_batches.json"
with open(REGULAR_BATCHES_FILE, 'r', encoding='utf-8') as f:
batches = json.load(f)
batch_map = {b['tt_value']: b for b in batches}
def get_session(url):
s = requests.Session()
s.headers.update({
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Chrome/120.0.0.0 Safari/537.36'
})
r = s.get(url, timeout=15)
soup = BeautifulSoup(r.text, 'html.parser')
token = soup.find('input', {'name': '_token'})['value']
payload = {
'COURSECD': soup.find('input', {'name': 'COURSECD'})['value'],
'SEMCODE': soup.find('input', {'name': 'SEMCODE'})['value'],
'RESULTTYPE': soup.find('input', {'name': 'RESULTTYPE'})['value'],
'session': soup.find('input', {'name': 'session'})['value'],
'tcc': soup.find('input', {'name': 'tcc'})['value'],
'p1': '', 'all': ''
}
return s, payload, token
def test_roll(session, payload, token, url, roll):
headers = {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': token,
'Referer': url,
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}
data = payload.copy()
data['EXAMROLLNUMBER'] = str(roll)
data['_token'] = token
try:
r = session.post(AJAX_URL, data=data, headers=headers, timeout=4)
if r.status_code == 200:
rj = r.json()
if 'html' in rj and len(rj['html']) > 200 and 'No Record Found' not in rj['html']:
return True
except Exception:
pass
return False
# Expanded college codes list across Durg region
colleges = [
"303", "304", "305", "307", "310", "312", "315", "320", "325", "331", "332", "333", "334", "335",
"337", "338", "339", "340", "341", "351", "352", "358", "366", "369", "370", "374", "381", "386",
"101", "102", "103", "201", "202", "203", "401", "402", "501"
]
def generate_probes(tr_code):
rolls = []
if tr_code == "TR00000001": # B.A.-B.Ed Part I
for c in ["369", "370", "374", "358", "335", "341", "351"]:
for s in [1, 2, 5, 10]:
rolls.extend([
f"{c}18144{s:03d}", f"18{c}144{s:03d}", f"9{c}144{s:03d}", f"9{c}144{s:04d}",
f"{c}18144{s:04d}", f"18{c}144{s:04d}", f"9{c}{s:04d}"
])
elif tr_code == "TR00000002": # B.Sc.-B.Ed Part I
for c in ["369", "370", "374", "358", "335", "341", "351"]:
for s in [1, 2, 3, 5, 10]:
rolls.extend([
f"{c}18137{s:03d}", f"18{c}137{s:03d}", f"9{c}137{s:03d}", f"9{c}137{s:04d}",
f"{c}18137{s:04d}", f"18{c}137{s:04d}", f"9{c}{s:04d}"
])
elif tr_code == "TR00000004": # MSW Sem 1
for c in colleges:
for s in [1, 2, 5]:
rolls.extend([f"{c}18125{s:03d}", f"18{c}125{s:03d}", f"18{c}125{s:04d}"])
elif tr_code == "TR00000005": # MSW Sem 3
for c in colleges:
for s in [1, 2, 5]:
rolls.extend([f"{c}17125{s:03d}", f"17{c}125{s:03d}", f"{c}17125{s:04d}"])
elif tr_code == "TR00000006": # MS Lib I Sc Sem 1
for c in colleges:
for s in [1, 2, 5]:
rolls.extend([f"{c}18121{s:03d}", f"18{c}121{s:03d}", f"{c}18121{s:04d}"])
elif tr_code == "TR00000007": # B.Ed Sem 1
for c in colleges:
for s in [1, 2, 5]:
rolls.extend([f"{c}18029{s:03d}", f"18{c}029{s:03d}", f"{c}18023{s:03d}"])
elif tr_code == "TR00000008": # B.Ed Sem 3
for c in colleges:
for s in [1, 2, 5, 10, 20]:
rolls.extend([f"{c}17029{s:03d}", f"17{c}029{s:03d}", f"{c}17023{s:03d}"])
elif tr_code == "TR00000009": # M.Sc Bio Tech Sem 1
for c in colleges:
for s in [1, 2, 5]:
rolls.extend([f"{c}18089{s:03d}", f"18{c}089{s:03d}"])
elif tr_code == "TR00000010": # M.Sc Bio Tech Sem 3
for c in colleges:
for s in [1, 2, 5]:
rolls.extend([f"{c}17089{s:03d}", f"17{c}089{s:03d}"])
return list(set(rolls))
target_trs = ["TR00000001", "TR00000002", "TR00000004", "TR00000005", "TR00000006", "TR00000007", "TR00000008", "TR00000009", "TR00000010"]
print("Running expanded targeted probes...")
for tr in target_trs:
if tr not in batch_map:
print(f"{tr}: Unpublished / Missing")
continue
b = batch_map[tr]
session, payload, token = get_session(b['link'])
probes = generate_probes(tr)
hits = []
for r in probes:
if test_roll(session, payload, token, b['link'], r):
hits.append(r)
print(f"{tr} ({b['description'][:45]}...): {len(hits)} HITS -> {hits}")

Xet Storage Details

Size:
4.86 kB
·
Xet hash:
68e26e72bde946c065ec7f932e7735bff54afc5095c0166a1e2ab12de366cc0c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.