#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/9/13 17:20
# @Author : longe
# @File : get_verify.py
# @Software: PyCharm
import time
import re
import requests
import urllib
from bs4 import BeautifulSoup
from urllib import parse
import time
from http import cookiejar
def get_captcha(session):
#抓取捕获验证码,这里没用from PIL import Image这个模块打开,因为我这默认打开ps,不知道什么原因
#下载获取的验证码,手动输入
url2='http://jz.gxrspx.com/js/login.js'
session.get(url2)
t_data=int(round(time.time() * 1000))
# 这里是通过分析网页源代码,它的参数就是用java的time()来取得随机值,但java是13位,所以这里要进行转换
url_end='http://jz.gxrspx.com/servlet/Image.Servlet?d=%s'%t_data
print(url_end)
# url_test='http://jz.gxrspx.com/servlet/Image.Servlet?d=1536932813438'
response=session.get(url_end)
with open('captcha.jpg','wb') as f:
f.write(response.content)
captcha=input()
return captcha
def login(session,captcha,username,password):
#通过获取的验证码进行登录,这里的密码是经过加密的,没有详细研究函数,有时间再研究了,这里抓包即可
url_check='http://jz.gxrspx.com/user/checkCaptcha'
check_data={
"Captcha": captcha
}
response=session.post(url_check,data=check_data)
print(response.content)
postdata={
"password":password,
"userName":username
}
posturl='http://jz.gxrspx.com/loginValid?'
response2=session.post(posturl,data=postdata)
print(response2.text)
def get_course(session,url):
#获取页数,遍历所有课程。将courseId存入列表
response=session.get(url)
response.encoding='utf-8'
pat = r'<div class="playin_grey tc" onclick="window.open\(\'(.*?)\'\);"'
re.compile(pat)
s = re.findall(pat, response.text)
print(s)
return s
def get_study(session,course):
#遍历课程
伪造数据绕过网上在线授课系统获取学时
最新推荐文章于 2023-08-30 15:14:41 发布