import requests url ='http://rc.k12.com.cn/cloudRes/res/download/id/440511' headers ={ 'Host':'rc.k12.com.cn', 'User-Agent':' Mozilla/5.0 (Windows NT 6.3; WOW64; rv:58.0) Gecko/20100101 Firefox/58.0', 'Accept':' text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language':'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2', 'Accept-Encoding':'gzip, deflate', # 'Referer':'http://rc.k12.com.cn/cloudRes/res/show/id/440511', 'Cookie':'symfony=225p3j7b9qtvlrkfh2sabptuu6; bdshare_firstime=1520642275017', 'Connection':'keep-alive', 'Upgrade-Insecure-Requests':'1', 'Pragma':'no-cache', 'Cache-Control':' no-cache', } html = requests.get(url,data =headers,allow_redirects=False) print(html.headers['Location'])
状态301永久重定向 302 临时重定向
取到正确的下载地址
https://ssl.k12.com.cn/k12cas/login?service=http%3A%2F%2Frc.k12.com.cn%2FcloudRes%2Fres%2Fdownload%2Fid%2F440511