Best Python code snippet using localstack_python
zuiyou.py
Source:zuiyou.py
...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 # å
容...
fetch_zuiyou.py
Source:fetch_zuiyou.py
...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 = ""...
test_misc.py
Source:test_misc.py
...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...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!