上篇博客使用cookie模拟post提交,但是session过期问题,会导致失效,所以采用session模拟提交
代码语言:javascript复制# -*- coding: utf-8 -*-
import requests
import os
import re
headers={
"Host":"user.liantu.com",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36",
}
login_url = "https://user.liantu.com/login/i/"
def get_session(headers, url):
user = {
"username": "*****",
"password": "******"
}
session = requests.session()
session.post(url, data=user, headers=headers)
return session
def post_apk(session):
version = os.listdir(r'C:Usersdev&keepDesktopkobe')[0]
url_save = "https://user.liantu.com/live/save/"
data = {
"name": "千随APP",
"link": "http://IP/test/{0}".format(version),
"id": "126646",
"style": "1",
}
result = session.post(url_save, data=data)
print(result.text)
session = get_session(headers, login_url)
post_apk(session)