|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
201801 
L0279 
大学物理实验Ⅲ 
2.50 
86 
正常 
3.60 
张由群 
2019/1/11 20:30:19 
201801 
L3184 
创新创业教育 
2 
82 
正常 
3.20 
贾建军 
2019/1/11 16:26:10 
一串像这样的输出结果(其实是成绩。。。),自己写了一个在学校教务处网站爬取考试成绩小程序
- import requests
- import time
- import hashlib
- from bs4 import BeautifulSoup
- #利用md5算法进行密码加密
- def encryption(studentid,timestamp,num):
- md5_1 = hashlib.md5()
- md5_1.update(num.encode('utf-8'))
- password1 = studentid + str(timestamp) + md5_1.hexdigest()
- md5_2 = hashlib.md5()
- md5_2.update(password1.encode('utf-8'))
- password = md5_2.hexdigest()
- return password
- #获取时间戳
- def get_timestamp():
- t = time.time()
- timestamp = int(round(1000*t))
- return timestamp
- def login():
- studentid = input('请输入学号:')
- ID = input('请输入身份证号:')
- timestamp = get_timestamp()
- password = encryption(studentid,timestamp,ID)
- #登录信息
- login_data = {
- 'Action':'Login',
- 'userName':studentid,
- 'pwd':password,
- 'sign':timestamp,
- }
- #post头信息
- headers_base = {
- 'Accept': '*/*',
- 'Accept-Encoding': 'gzip, deflate, sdch',
- 'Accept-Language': 'zh-CN,zh;q=0.9',
- 'Connection': 'keep-alive',
- 'Host': '202.115.133.173:805',
- 'Origin': 'http://202.115.133.173:805',
- 'Referer': 'http://202.115.133.173:805/Login.html',
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3702.0 Safari/537.36',
- 'X-Requested-With': 'XMLHttpRequest',
- }
- #创建session对象,保存cookies信息
- session = requests.session()
- url = 'http://202.115.133.173:805/Common/Handler/UserLogin.ashx'
- #利用登录信息网页信息访问网站
- session.post(url,headers = headers_base,data = login_data)
- #直接打开需要登录才可以访问的网站
- response = session.get('http://202.115.133.173:805/SearchInfo/Score/ScoreList.aspx')
- response.encoding = 'utf-8'
- #对网页进行解析,并保存在soup对象
- soup = BeautifulSoup(response.text,'html.parser')
- #对网页进行筛选
- for itmes in soup.select('.listUl li'):
- print(itmes.text)
- if __name__ == '__main__':
- login()
复制代码
怎么把那个输出结果改成一行一行的:
201801  L0279  大学物理实验Ⅲ  2.50  86  正常  3.60  张由群  2019/1/11 20:30:19 
201801  L3184  创新创业教育  2  82  正常  3.20  贾建军  2019/1/11 16:26:10 
能对齐肯定是最好的啦,谢谢大佬 |
|