37,737
社区成员
发帖
与我相关
我的任务
分享
import requests
from lxml import etree
s = requests.Session()
url = "http://acm.nyist.net/JudgeOnline/login.php"
data = {
'userid': '*****', # 账号密码保密= =
'password': '*****',
'btn_submit': '登录'
}
headers = {
'User-Agent': "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0",
'Content-Type': 'application/x-www-form-urlencoded',
'Connection': 'keep-alive',
'Cache-Control': 'max-age=0',
'Content-Length': '107',
'Host': 'acm.nyist.net',
'Origin': 'http://acm.nyist.net',
'Referer': 'http://acm.nyist.net/JudgeOnline/login.php',
}
result = s.post(url, data, headers)
print(result.url)
html2 = s.get("http://acm.nyist.net/JudgeOnline/code.php?runid=1675386")
# print(html2.text)
select2 = etree.HTML(html2.text)
content2 = select2.xpath('//*[@id="highlighter_511612"]/div[2]/text()')
for each in content2:
print(each)