python 批量执行脚本-oracle 批量执行脚本
发布时间:2023-02-08 11:13   浏览次数:次   作者:佚名
          
          本文内容是关于python脚本如何模拟界面实现批量用户激活(代码)。 具有一定的参考价值。 有需要的朋友可以参考一下。 希望对您有所帮助。
1。目的
通过模拟接口方式实现批量用户激活
2.分析
A、接口包括body和head,body中的一些变量是必填字段,包括用户信息。
B. 用户信息列表可以组织成ott_after_check_device文件。
C、将ott_after_check_device文件转换成列表数据类型python 批量执行脚本python 批量执行脚本,将其用户信息替换到body.xml文件中。
3.脚本实现
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder
def get_txt_after_check_device():
    ott_after_check_device = '.\\ott_after_check_device.txt'
    f = open(ott_after_check_device)
    lines = f.readlines()
    all_list_device = []

    for line in lines:
        line = line.replace("\n", '')
        list_device = line.split(',')
        all_list_device.append(list_device)
    return all_list_device
def ott_boss(list_device):
    sleep_time = 0.001
    # print len(list_device)
    for i in range(len(list_device)):
        print u'新开户数 :', i + 1
        time.sleep(sleep_time)
        acc_num = list_device[i][0]
        stb_id = list_device[i][1]
        print 'STBID : ', stb_id
        account = list_device[i][2]
        url = 'http://10.2.214.133:6600/oss/rest/mango/bossManagement/syncOrder'

        mul = MultipartEncoder(
                fields={
                    'xmlhead': ' '
                               '0100 '
                               '0 '
                               ''
                               'IPTVB412 '
                               'T2101057 '
                               '0 '
                               ' '
                               ''
                               'BOSS '
                               '00 '
                               ''
                               'OTT '
                               '210 '
                               ' '
                               ' '

                               ''
                               '2018092517323481311686 '
                               '2018092517323416388122 '
                               '20180211173234 '
                               '   ',
                    'xmlbody': '       '
                               '73120180111000007 '
                               '1 '
                               ''
                               '01 '
                               '%s '
                               '09 '
                               '06 '
                               '20180925171922 '
                               '52 '
                               '8121 '
                               '738815023717 '

                               ' '
                               ''
                               ' '
                               ' '
                               ' '
                               ' '
                               'K381 '
                               ' '
                               ''
                               '1 '
                               '%s '
                               '%s '
                               '111111 '
                               '2 '
                               '20180925171922 '
                               '08 '
                               'mango '
                               'defaultBasicProduct '

                               '01 '
                               ' '
                               '    '
                               ']]>   ' % (acc_num, stb_id, account)
                }
        )
        header = {'Content-Type': mul.content_type}
        body = mul
        response = requests.post(url, data=body, headers=header)
        print response.content
        print response.status_code
if __name__ == '__main__':
    ott_boss(get_txt_after_check_device())
登录复制
以上就是python脚本如何模拟界面实现批量用户激活的详细内容(代码)。 更多内容请关注php中文网其他相关文章!
免责声明:本文转载于:博客园,如有侵权,请联系admin@php.cn删除

 
上一篇 
  
        