How to use parse_chunked_data method in localstack

Best Python code snippet using localstack_python

zuiyou.py

Source:zuiyou.py Github

copy

Full Screen

...58 time_string = '{:.3f}'.format(time.time()).replace('.', '')59 return eval(time_string)60# 获取全部弹幕61def danmu(pid, vid):62 def parse_chunked_data(t):63 data = {"pid":pid,"vid":vid,"t":t,"h_av":"4.7.3","h_dt":0,"h_os":25,"h_app":"zuiyou","h_model":"MI 5X","h_did":"866655030396869_02:00:00","h_nt":1,"h_m":116456192,"h_ch":"xiaomi","h_ts":unixtime(),"token":"TeKfNCRqAec6tUN7wn3-JSGqoTTXBsx0YTPoKXva9q6z94jiDk2da1MuSuhRdh-G8Bp3-","android_id":"57b9b8465c2e440b"}64 sign = messagesdigest(str(data))65 # 弹幕地址66 url = 'http://dmapi.izuiyou.com/danmaku/list?sign=' + str(sign)67 headers = {"User-Agent": "okhttp/3.11.0 Zuiyou/4.7.1"}68 try:69 r = requests.post(url, headers=headers, data=json.dumps(data))70 response = r.json()71 if response["ret"] == 1:72 chunked_danmu = response["data"]["list"]73 parser_danmu(chunked_danmu)74 # print('{}\n\n'.format(chunked_danmu))75 print("\n")76 # 判断弹幕是否加载完成的标志,1为未完成,0为完成77 more = response["data"]["more"]78 # 下次弹幕加载的开始时间79 t = response["data"]["t"]80 return more, t81 else:82 print("sign签名出错哦!出错pid={},vid={}\n请稍后重试!".format(pid, vid))83 except RequestException as e:84 print(e)85 t = 086 more, t, = parse_chunked_data(t)87 while more == 1:88 more, t = parse_chunked_data(t)89# 首页推荐内容解析90def parser(items):91 nums = len(items['data']['list'])92 # 用于提取视频中的pid, vid93 # video = []94 for i in range(nums):95 item = items['data']['list'][i]96 # print("{}\n".format(item))97 # 发布人姓名98 if 'memeber' in item:99 name = item['member']['name']100 else:101 name = ""102 # 内容...

Full Screen

Full Screen

fetch_zuiyou.py

Source:fetch_zuiyou.py Github

copy

Full Screen

...58 time_string = '{:.3f}'.format(time.time()).replace('.', '')59 return eval(time_string)60# 获取全部弹幕61def danmu(pid, vid):62 def parse_chunked_data(t):63 data = {"pid": pid, "vid": vid, "t": t, "h_av": "4.7.3", "h_dt": 0, "h_os": 25, "h_app": "zuiyou",64 "h_model": "MI 5X", "h_did": "866655030396869_02:00:00", "h_nt": 1, "h_m": 116456192, "h_ch": "xiaomi",65 "h_ts": unixtime(), "token": "TeKfNCRqAec6tUN7wn3-JSGqoTTXBsx0YTPoKXva9q6z94jiDk2da1MuSuhRdh-G8Bp3-",66 "android_id": "57b9b8465c2e440b"}67 sign = messagesdigest(str(data))68 # 弹幕地址69 url = 'http://dmapi.izuiyou.com/danmaku/list?sign=' + str(sign)70 headers = {"User-Agent": "okhttp/3.11.0 Zuiyou/4.7.1"}71 try:72 r = requests.post(url, headers=headers, data=json.dumps(data))73 response = r.json()74 if response["ret"] == 1:75 chunked_danmu = response["data"]["list"]76 parser_danmu(chunked_danmu)77 # print('{}\n\n'.format(chunked_danmu))78 print("\n")79 # 判断弹幕是否加载完成的标志,1为未完成,0为完成80 more = response["data"]["more"]81 # 下次弹幕加载的开始时间82 t = response["data"]["t"]83 return more, t84 else:85 print("sign签名出错哦!出错pid={},vid={}\n请稍后重试!".format(pid, vid))86 except RequestException as e:87 print(e)88 t = 089 more, t, = parse_chunked_data(t)90 while more == 1:91 more, t = parse_chunked_data(t)92# 首页推荐内容解析93def parser(items):94 nums = len(items['data']['list'])95 # 用于提取视频中的pid, vid96 # video = []97 for i in range(nums):98 item = items['data']['list'][i]99 print(item)100 # print("{}\n".format(item))101 # 发布人姓名102 if 'memeber' in item:103 name = item['member']['name']104 else:105 name = ""...

Full Screen

Full Screen

test_misc.py

Source:test_misc.py Github

copy

Full Screen

...7 env = aws_stack.Environment.from_json({'prefix': 'foobar1'})8 assert env.prefix == 'foobar1'9 env = aws_stack.Environment.from_string('foobar2')10 assert env.prefix == 'foobar2'11def test_parse_chunked_data():12 # See: https://en.wikipedia.org/wiki/Chunked_transfer_encoding13 chunked = '4\r\nWiki\r\n5\r\npedia\r\nE\r\n in\r\n\r\nchunks.\r\n0\r\n\r\n'14 expected = 'Wikipedia in\r\n\r\nchunks.'15 parsed = parse_chunked_data(chunked)16 assert parsed.strip() == expected.strip()17# This test is not enabled in CI, it is just used for manual18# testing to debug https://github.com/localstack/localstack/issues/21319def run_parallel_download():20 file_length = 1000000021 class DownloadListener(ProxyListener):22 def forward_request(self, method, path, data, headers):23 sleep_time = int(path.replace('/', ''))24 time.sleep(sleep_time)25 response = Response()26 response.status_code = 20027 response._content = ('%s' % sleep_time) * file_length28 return response29 test_port = 12124...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful