


How to simulate interface with python script to implement batch user activation (code)
本篇文章给大家带来的内容是关于python脚本如何模拟接口实现批量用户开通(代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
1、目的
通过模拟接口方法,实现批量用户开通
2、分析
A、接口含body和head部分,其中body中的某些变量为必填字段,包含用户的信息。
B、用户信息清单可以整理成ott_after_check_device文件。
C、将ott_after_check_device文件转换成列表数据类型,将其用户信息对应替换到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': '<?xml version="1.0" encoding="UTF-8"?> <InterBOSS>' '<Version>0100</Version>' '<TestFlag>0</TestFlag>' '<BIPType>' '<BIPCode>IPTVB412</BIPCode>' '<ActivityCode>T2101057</ActivityCode>' '<ActionCode>0</ActionCode>' '</BIPType>' '<RoutingInfo>' '<OrigDomain>BOSS</OrigDomain>' '<RouteType>00</RouteType>' '<Routing>' '<HomeDomain>OTT</HomeDomain>' '<RouteValue>210</RouteValue>' '</Routing>' '</RoutingInfo>' '<TransInfo>' '<SessionID>2018092517323481311686</SessionID>' '<TransIDO>2018092517323416388122</TransIDO>' '<TransIDOTime>20180211173234</TransIDOTime>' '</TransInfo> </InterBOSS>', 'xmlbody': '<?xml version="1.0" encoding="UTF-8"?> <InterBOSS> <SvcCont><![CDATA[<?xml ' 'version="1.0" encoding="UTF-8"?> <OrdSynReq>' '<PkgSeq>73120180111000007</PkgSeq>' '<RecNum>1</RecNum>' '<UD1>' '<IDType>01</IDType>' '<IDV>%s</IDV>' '<Brand>09</Brand>' '<Opr>06</Opr>' '<OprT>20180925171922</OprT>' '<BizType>52</BizType>' '<Seq>8121</Seq>' '<BroadbandID>738815023717</BroadbandID>' '<ZipCode></ZipCode>' '<Address></Address>' '<UserName></UserName>' '<UserSex></UserSex>' '<IDCardType></IDCardType>' '<IDCardNum></IDCardNum>' '<AreaCode>K381</AreaCode>' '<GroupID></GroupID>' '<POCont>' '<ActType>1</ActType>' '<StbID>%s</StbID>' '<Account>%s</Account>' '<Password>111111</Password>' '<ChrgType>2</ChrgType>' '<EffetiTime>20180925171922</EffetiTime>' '<Channel>08</Channel>' '<SPID>mango</SPID>' '<BizCode>defaultBasicProduct</BizCode>' '<BizKind>01</BizKind>' '</POCont>' '</UD1> </OrdSynReq> ' ']]></SvcCont> </InterBOSS>' % (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())
The above is the detailed content of How to simulate interface with python script to implement batch user activation (code). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Summary of some reasons why crontab scheduled tasks are not executed. Update time: January 9, 2019 09:34:57 Author: Hope on the field. This article mainly summarizes and introduces to you some reasons why crontab scheduled tasks are not executed. For everyone Solutions are given for each of the possible triggers, which have certain reference and learning value for colleagues who encounter this problem. Students in need can follow the editor to learn together. Preface: I have encountered some problems at work recently. The crontab scheduled task was not executed. Later, when I searched on the Internet, I found that the Internet mainly mentioned these five incentives: 1. The crond service is not started. Crontab is not a function of the Linux kernel, but relies on a cron.

PyCharm is a powerful Python integrated development environment that provides a wealth of functions and tools to help developers improve efficiency. Among them, PyInstaller is a commonly used tool that can package Python code into an executable file (EXE format) to facilitate running on machines without a Python environment. In this article, we will introduce how to use PyInstaller in PyCharm to package Python code into EXE format, and provide specific

Orange3 is a powerful open source data visualization and machine learning tool. It has rich data processing, analysis and modeling functions, providing users with simple and fast data mining and machine learning solutions. This article will briefly introduce the basic functions and usage of Orange3, and combine it with actual application scenarios and Python code cases to help readers better master the usage skills of Orange3. The basic functions of Orange3 include data loading, data preprocessing, feature selection, model establishment and evaluation, etc. Users can use the intuitive interface to drag and drop components to easily build data processes. At the same time, more complex data processing and modeling tasks can also be completed through Python scripts. Below we will go through a practical

How to read Excel data using PyCharm? The steps are as follows: install the openpyxl library; import the openpyxl library; load the Excel workbook; access a specific worksheet; access cells in the worksheet; traverse rows and columns.

1. First open pycharm and enter the pycharm homepage. 2. Then create a new python script, right-click - click new - click pythonfile. 3. Enter a string, code: s="-". 4. Then you need to repeat the symbols in the string 20 times, code: s1=s*20. 5. Enter the print output code, code: print(s1). 6. Finally run the script and you will see our return value at the bottom: - repeated 20 times.

Website subdomain query tools include: 1. Whois Lookup: can query the registration information of a domain name, including subdomain names; 2. Sublist3r: can automatically scan the subdomain name of a domain name with the help of search engines and other tools; 3. DNSdumpster: can query Information such as the subdomain name, IP address and DNS record of the domain name; 4. Fierce: You can query the subdomain name information of the domain name through the DNS server: 5. Nmap; 6. Recon-ng; 7. Google Hacking.

Flask installation and configuration tutorial: A tool to easily build Python Web applications, specific code examples are required. Introduction: With the increasing popularity of Python, Web development has become one of the necessary skills for Python programmers. To carry out web development in Python, we need to choose a suitable web framework. Among the many Python Web frameworks, Flask is a simple, easy-to-use and flexible framework that is favored by developers. This article will introduce the installation of Flask framework,

How to run Python scripts in Linux systems As a powerful scripting language, Python is widely used in Linux systems. In this article, I will introduce you how to run Python scripts in Linux systems and provide specific code examples. Install Python First, make sure Python is installed on your Linux system. Enter the following command in the terminal to check whether Python is installed on your system: python --version if it is displayed
