???Har????????? (LR ???)
???????????? ???????[ 2016/9/7 14:53:39 ] ?????????????? ??? ????????
???????
????HTTP Archive (HAR) format ??httpЭ?齻????鵵?????
???????????????????utf8?????json????????洢?????е?http?????http?????????????????е?head??body??
??????λ??HAR???
??????????proxy?????????fiddler??charles??????????charles?????????har?????????????????? export ??????棺
????????????????????http????
??????charles?У?????????????????????? ???????????????????????????
????1. ??????????????????????proxy???????????????
????2. ?????????????????????????????????????????????????????????????????????
????3. ???????????????????????tcp??udp????????Socket?????????????????????????????Э???? ???????????????ж???httpЭ???? ???÷??????????????????????????????????????
????????har
???????????????????????????????http??????????har????????н?????????????????????????????loadrunner ????????
????????python???????£?
????#!/usr/bin/env python
????# -*- coding: utf-8 -*-
????from optparse import OptionParser
????import os
????import sys
????import json
????# check env
????if sys.version_info < (3?? 4):
????raise RuntimeError('At least Python 3.4 is required.')
????restype = ('js'?? 'css'?? 'jpg'?? 'gif'?? 'ico'?? 'png')
????def list2dic(headers):
????header_dic = dict()
????for head in headers:
????if head['name'] in header_dic:
????header_dic[head['name']] = header_dic[head['name']] + '??' + head['value']
????else:
????header_dic[head['name']] = head['value']
????return header_dic
????def dictoand(dct):
????res_list = list()
????for tp in dct:
????res_list.append('%s=%s' % (tp['name']?? tp['value']))
????return '&'.join(res_list)
????def dict2lr(lrsc):
????tmpl = '''
????web_custom_request("%(name)s"??
????"URL=%(url)s"??
????"Method=%(method)s"??
????"Resource=%(res)s"??
????"Referer=%(referer)s"??
????"EncType=%(enctype)s"??
????"Body=%(body)s"??
????LAST);'''
????# url
????url = lrsc['url']
????method = lrsc['method']
????name = url.split('/')[-1]
????name = name.split('?')[0]
????suff = url.split('.')[-1]
????# Resource type
????global restype
????res = '0'
????if suff in restype:
????res = '1'
????# Content-Type
????enctype = ''
????if 'Content-Type' in lrsc:
????enctype = lrsc['Content-Type']
????# Referer
????referer = ''
????if 'Referer' in lrsc:
????referer = lrsc['Referer']
????# Body
????body = ''
????if 'posttext' in lrsc:
????body = lrsc['posttext']
????elif 'postparams' in lrsc:
????body = dictoand(lrsc['postparams'])
????body = body.replace('"'?? '\"')
????res = tmpl % {'name': name?? 'url': url?? 'method': method?? 'enctype': enctype?? 'referer': referer?? 'res': res??
????'body': body}
????# Head
????if 'SOAPAction' in lrsc:
????res = ("
" + ' web_add_header("SOAPAction"?? "%s")' + ";
" + res) % lrsc['SOAPAction']
????return res
????def parhar(harfile):
????res = list()
????try:
????FH = open(harfile?? mode='r'?? encoding='utf-8'?? closefd=True)
????all = json.load(FH)
????FH.close()
????except Exception as ex:
????print('Open har file errr: %s' % ex)
????quit()
????har_ver = all['log']['version']
????creater = all['log']['creator']['name']
????entries = all['log']['entries']
????ct = len(entries)
????for et in entries:
????stm = et['startedDateTime']
????req = et['request']
????rsp = et['response']
????lrsc = dict()
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11