import requests
def rqu(length):
with open(f'test.pdf', 'ab+') as f:
r1 = length
r2 = r1 + 1048575
headers = {
"authority": "www.qxbsk.com",
"accept": "*/*",
"accept-language": "zh-CN,zh;q=0.9",
"cache-control": "no-cache",
"pragma": "no-cache",
"range": f"bytes={r1}-{r2}",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
}
response = requests.get(url, headers=headers, cookies=cookies, params=params, stream=True)
response.encoding = 'utf-8'
f.write(response.content)
def get_total_length(params):
response = requests.get(url, headers=headers, cookies=cookies, params=params, stream=True)
response.encoding = 'utf-8'
total_length = response.headers['Content-Length']
return total_length
if __name__ == '__main__':
headers = {
"authority": "www.qxbsk.com",
"accept": "*/*",
"accept-language": "zh-CN,zh;q=0.9",
"cache-control": "no-cache",
"pragma": "no-cache",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
}
cookies = {
"security_session_verify": "",
"home_lang": "cn",
"admin_lang": "cn",
"PHPSESSID": ""
}
url = "https://www.qxbsk.com/home/test/uploadss"
params = {
"file": "OTc5MzQ0",
"__token__": ""
}
totalLength = get_total_length(params)
print(totalLength)
if int(totalLength) < 1048576:
rqu(0)
print(f"下载中...{totalLength}/{totalLength}")
else:
for pLength in range(0, int(totalLength), 1048576):
rqu(pLength)
print(f"下载中...{pLength}/{totalLength}")
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62