Skip to content

Commit

Permalink
Update scraper.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BCG12345 committed Jan 13, 2024
1 parent f58bf96 commit f2316be
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,39 @@
# All that matters is that your final data is written to an SQLite database
# called "data.sqlite" in the current working directory which has at least a table
# called "data".






import requests

url = 'http://pu.edu.pk/home/results_show/2167'
payload = {
'result_title': 'Bachelor of Commerce Part-II, Annual Examination 2008',
'roll_no': '2',
'submitcontact': 'Submit'
}

# Add headers as observed in the DevTools
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Referer':url,
'Host': 'pu.edu.pk',
'Origin': 'http://pu.edu.pk',
'Upgrade-Insecure-Requests': '1',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'en-US,en;q=0.9',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
}

response = requests.post(url, data=payload, headers=headers)

if response.status_code == 200:
data = response.text
print(data)
else:
print(f"Failed to retrieve data. Status code: {response.status_code}")

0 comments on commit f2316be

Please sign in to comment.