### datax-web 使用 python3
### datax-web 创建任务
- 任务类型:python 任务
- 代码如下:
#!/usr/bin/python2
# -*- coding:UTF-8 -*-
import requests
#登录并获取cookie
login_url="https://***.***.com/xxl-job-admin/login"
#表单传值
login_head={"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Connection": "keep-alive"}
#登录的参数
login_body={"userName":"admin","password":"123456"}
#post请求 进行登录
res = requests.post(url=login_url, headers=login_head, data=login_body, allow_redirects=False)
cookies = res.cookies
return_cookie = requests.utils.dict_from_cookiejar(cookies)['cookie_default']
print("cookie==>>"+return_cookie)
param_cookies= {"cookie_default":return_cookie}
# Construct the URL for the xxljob API
url_xxl = "https://***.***.com/xxl-job-admin/jobinfo/start"
data_body={"id":"11"}
# Send a POST request to the xxljob API with your credentials
response = requests.post(url=url_xxl, cookies=param_cookies, data=data_body)
print(response.json().get("code"))