import requests
from bs4 import BeautifulSoup
s=requests.Session()
Base_URL="view-source:http://210.43.224.19/oj/csrf.php"
Login_URL="http://210.43.224.19/oj/loginpage.php"
test_url="http://210.43.224.19/oj/contest.php?cid=2263"
def get_html_csrf(url):
header={
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
}
response=requests.get('http://210.43.224.19/oj/csrf.php',headers=header)
print(response.status_code)
#t.encoding=
#response.text()
soup=BeautifulSoup(response.text,"html.parser")
return soup.find_all("input")[0].attrs['value']
def login(url,csrf):
header={
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
}
data={
"user-id":"16110321011",
"password":"985170",
"csrf":csrf,
}
s=requests.Session()
response=s.post(url,data=data,headers=header)
res=s.get(test_url,cookies=response.cookies,headers=header)
res.encoding='utf-8'
return res.text
if __name__=="__main__":
csrf=get_html_csrf(Base_URL)
print(login(Login_URL,csrf))
from bs4 import BeautifulSoup
s=requests.Session()
Base_URL="view-source:http://210.43.224.19/oj/csrf.php"
Login_URL="http://210.43.224.19/oj/loginpage.php"
test_url="http://210.43.224.19/oj/contest.php?cid=2263"
def get_html_csrf(url):
header={
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
}
response=requests.get('http://210.43.224.19/oj/csrf.php',headers=header)
print(response.status_code)
#t.encoding=
#response.text()
soup=BeautifulSoup(response.text,"html.parser")
return soup.find_all("input")[0].attrs['value']
def login(url,csrf):
header={
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
}
data={
"user-id":"16110321011",
"password":"985170",
"csrf":csrf,
}
s=requests.Session()
response=s.post(url,data=data,headers=header)
res=s.get(test_url,cookies=response.cookies,headers=header)
res.encoding='utf-8'
return res.text
if __name__=="__main__":
csrf=get_html_csrf(Base_URL)
print(login(Login_URL,csrf))