代码拉取完成,页面将自动刷新
同步操作将从 abc-edb-fund/add_category_and_value 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/8/7 11:23
# @Author : Orient
# @File : update_data.py
# @Software: PyCharm
import requests
import json
import xlrd
params = {"passWord": "123456", "userName": "lidongfang"}
class get_cookie(object):
"""docstring for get_cookie."""
def __init__(self):
super(get_cookie, self).__init__()
def cookie(self):
url = 'http://backend.aqlicai.cn/login/loginIn.form'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'}
# 请求login接口
response = requests.post(url=url, params=params, headers=headers)
# 获取response中的cookies
cookies = response.cookies.get_dict()
return cookies
class encaps_data(object):
"""docstring for encapsulate_data."""
def __init__(self, ):
super(encaps_data, self).__init__()
self.dict = {
'id':'',
'categoryId':'',
'indicatorCode':'',
'indicatorData':'',
'indicatorTime':'',
'status':''}
def get_column_index(self,table, columnName):
columnIndex = None
for i in range(table.ncols):
if (table.cell_value(0, i) == columnName):
columnIndex = i
break
return columnIndex
def encaps(self):
"""
Args:
self,file_id
Returns:
data_json
"""
file_id = int(input('file_id: '))
with xlrd.open_workbook(f'./update_data/update_{file_id}.xls') as tb:
ts = tb.sheet_by_index(0)
for key in self.dict.keys():
self.dict[key] = ts.cell_value(1, self.get_column_index(ts,key))
data = {
"categoryId": int(self.dict['categoryId']),
"id": int(self.dict['indicatorCode']),
"edbIndicatorDataVOS": [{
"id": int(self.dict['id']),
"indicatorTime": "2018-08-07",
"indicatorData": str(self.dict['indicatorData']),
"status": str(int(self.dict['status']))
}]}
return json.dumps(data)
class update(get_cookie,encaps_data):
"""docstring for update."""
def __init__(self, ):
super(update, self).__init__()
def update(self):
"""批量修改indicator_data
Args:
self
Returns:
update status
"""
url = 'http://backend.aqlicai.cn/edb/center/saveData.form'
Headers = {'Content-Type': 'application/json',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0',
'X-Requested-With': 'XMLHttpRequest'}
data_json = encaps_data.encaps(self)
cookie = get_cookie.cookie(self)
result = requests.post(url,data = data_json, headers = Headers, cookies = cookie)
print(result.text)
test = update()
test.update()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。