Delete test_login.py
This commit is contained in:
@@ -1,45 +0,0 @@
|
|||||||
import requests
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
import sys
|
|
||||||
|
|
||||||
url = 'https://campus.udelaciudad.edu.ar/login/index.php'
|
|
||||||
session = requests.Session()
|
|
||||||
response = session.get(url, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'})
|
|
||||||
|
|
||||||
soup = BeautifulSoup(response.text, 'html.parser')
|
|
||||||
token_input = soup.find('input', {'name': 'logintoken'})
|
|
||||||
if not token_input:
|
|
||||||
print("logintoken not found.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
logintoken = token_input.get('value')
|
|
||||||
print(f"Token: {logintoken}")
|
|
||||||
|
|
||||||
# POST login
|
|
||||||
login_data = {
|
|
||||||
'username': '34247025',
|
|
||||||
'password': 'SOY*Poderoso22',
|
|
||||||
'logintoken': logintoken
|
|
||||||
}
|
|
||||||
|
|
||||||
post_response = session.post(url, data=login_data, headers={
|
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'
|
|
||||||
})
|
|
||||||
|
|
||||||
print(f"Login POST status: {post_response.status_code}")
|
|
||||||
if 'loginerrormessage' in post_response.text:
|
|
||||||
print("Login error message found!")
|
|
||||||
else:
|
|
||||||
print("No login errormessage found. Maybe success?")
|
|
||||||
|
|
||||||
# Try downloading the PDF
|
|
||||||
pdf_url = 'https://campus.udelaciudad.edu.ar/mod/customcert/view.php?id=209134&downloadown=1'
|
|
||||||
pdf_response = session.get(pdf_url, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'})
|
|
||||||
print(f"PDF GET status: {pdf_response.status_code}")
|
|
||||||
print(f"Content-Type: {pdf_response.headers.get('Content-Type')}")
|
|
||||||
if 'application/pdf' in pdf_response.headers.get('Content-Type', ''):
|
|
||||||
print("Successfully downloaded PDF!")
|
|
||||||
else:
|
|
||||||
print("Did not download PDF. HTML start:")
|
|
||||||
print(pdf_response.text[:500])
|
|
||||||
Reference in New Issue
Block a user