python生成url测试用例

generate_url.py

#!/usr/bin/env python

import random
import os, sys

channels = [ \
    "BTV2", "BTV3", "BTV4", "BTV5", "BTV6", "BTV7", "BTV8", "BTV9", \
    "BTVWorld", "CCTV12", "CCTV2", "CCTV3", "CCTV5", "CCTV6", "CCTV6World", "CCTV7", \
    "CCTV8", "CCTV9World", "CCTVA", "CCTVChild", "CCTVE", "CCTVEN", "CCTVF", "CCTVFYYY", \
    "CCTVHJJC", "CCTVMusic", "CCTVNEWS", "CCTVR", "CETV1", "CETV3", "ChongQingTV", "ChongQingWorld", \
    "GZChild", "GZEnglish", "GZFinance", "GZJingSai", "GZMovie", "GanSuTV", "GuangXiTV", "GuiZhouTV", \
    ]

host = '10.160.1.21'
date = '2014/10/31'
bitrates = ['800000']
ts_path = '/opt/online01/stream'

with open('/opt/urllist', 'wt') as f:
    for i in xrange(1, 2**16):
        channel = random.choice(channels)
        bitrate = random.choice(bitrates)
        path = ''.join([ts_path, '/', bitrate, '/', channel, '/', date])
        filenames = os.listdir(path)
        filename = random.choice(filenames)
        ts_url = ''.join(['http://', host, '/', 'online01/stream/', bitrate, '/', channel, '/', date, '/', filename, '\n'])
        f.write(ts_url) 

posted on 2014-10-31 13:46 北京涛子 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/liujitao79/p/4064883.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值