How to use append_list method in PyHamcrest

Best Python code snippet using PyHamcrest_python

web_crawler.py

Source:web_crawler.py Github

copy

Full Screen

1def craw_new_data(year,month,date):2 import requests3 import pandas as pd4 from bs4 import BeautifulSoup5 import numpy6 import csv7 import time8 9 info = f'{year}/{month}/{date}'10 url = 'https://www.taifex.com.tw/cht/3/optDailyMarketReport'11 payload = {'queryType':'2',12 'marketCode':'0',13 'dateaddcnt':'',14 'commodity_id':'TXO',15 'commodity_id2':'',16 'MarketCode':'0',17 'commodity_idt':'TXO',18 'commodity_id2t':'',19 'commodity_id2t2':'',20 'queryDate':info21 }22 encoding = 'utf8'23 r = requests.post(url,data=payload)24 r.encoding = encoding25 soup = BeautifulSoup(r.content, 'html.parser')26 data = pd.DataFrame(columns=['契約','到期月份(週別)','履約價','買賣權','開盤價','最高價','最低價','最後成交價','結算價','盤後交易時段成交量','一般交易時段成交量','合計成交量','未沖銷契約量'])27 append_list = {}28 count = 029 for i in soup.find_all('tr'):30 for j in i.find_all('td',class_ = '12bk'):31 count+=132 if count > 18:33 if (count-18)%13 == 0:34 data = data.append(append_list, ignore_index=True)35 append_list = {}36 append_list['契約'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')37 elif (count-18)%13 == 1:38 append_list['到期月份(週別)'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')39 elif (count-18)%13 == 2:40 append_list['履約價'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')41 elif (count-18)%13 == 3:42 append_list['買賣權'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')43 elif (count-18)%13 == 4:44 append_list['開盤價'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')45 elif (count-18)%13 == 5:46 append_list['最高價'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')47 elif (count-18)%13 == 6:48 append_list['最低價'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')49 elif (count-18)%13 == 7:50 append_list['最後成交價'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')51 elif (count-18)%13 == 8:52 append_list['結算價'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')53 elif (count-18)%13 == 9:54 append_list['盤後交易時段成交量'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')55 elif (count-18)%13 == 10:56 append_list['一般交易時段成交量'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')57 elif (count-18)%13 == 11:58 append_list['合計成交量'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')59 elif (count-18)%13 == 12:60 append_list['未沖銷契約量'] = j.text.replace('\n','').replace(' ','').replace('\t','').replace('\r','')61 try:62 data.to_csv(f'./static/option_data/option_data_{year}_{month}_{date}.csv',index=False,encoding='cp950')63 except:64 data.to_csv(f'../static/option_data/option_data_{year}_{month}_{date}.csv',index=False,encoding='cp950')65 return data66if __name__ == "__main__":...

Full Screen

Full Screen

leaderboard.py

Source:leaderboard.py Github

copy

Full Screen

12class Leaderboard:34 def __init__(self):5 self.leaders = []6 self.tank_leaders = []7 self.fighter_leaders = []8 self.assassin_leaders = []9 self.cleric_leaders = []10 self.artificer_leaders = []11 self.mage_leaders = []12 self.dark_druid_leaders = []13 self.monk_leaders = []1415 def check_leaderboard(self, raid, hero, time):1617 def class_checks(board, raid, hero_stats):18 if len(board) < 10:19 board.append(hero_stats)20 board.sort(key=lambda x: x[1], reverse=False)21 else:22 for hero in board:23 if raid.difficulty > hero.difficulty:24 board.append(hero_stats)25 board.sort(key=lambda x: x[1], reverse=False)26 return True27 return False2829 def chop_tail(board):30 board.remove(board[-1])3132 append_list = [hero.name, raid.difficulty, hero.class_]3334 if hero.class_ == "Tank":35 chop = class_checks(self.tank_leaders, raid, append_list)36 if chop:37 chop_tail(self.tank_leaders)3839 elif hero.class_ == "Fighter":40 chop = class_checks(self.fighter_leaders, raid, append_list)41 if chop:42 chop_tail(self.fighter_leaders)4344 elif hero.class_ == "Assassin":45 chop = class_checks(self.assassin_leaders, raid, append_list)46 if chop:47 chop_tail(self.assassin_leaders)4849 elif hero.class_ == "Cleric":50 chop = class_checks(self.cleric_leaders, raid, append_list)51 if chop:52 chop_tail(self.cleric_leaders)5354 elif hero.class_ == "Mage":55 chop = class_checks(self.mage_leaders, raid, append_list)56 if chop:57 chop_tail(self.mage_leaders)5859 elif hero.class_ == "Artificer":60 chop = class_checks(self.artificer_leaders, raid, append_list)61 if chop:62 chop_tail(self.artificer_leaders)6364 elif hero.class_ == "Dark Druid":65 chop = class_checks(self.dark_druid_leaders, raid, append_list)66 if chop:67 chop_tail(self.tank_leaders)6869 elif hero.class_ == "Monk":70 chop = class_checks(self.monk_leaders, raid, append_list)71 if chop:72 chop_tail(self.monk_leaders)7374 if len(self.leaders) < 10:75 self.leaders.append(append_list)76 self.leaders.sort(key=lambda x: x[1], reverse=False)77 else:78 for hero in self.leaders:79 if raid.difficulty > hero.difficulty:80 self.leaders.append(append_list)81 self.leaders.sort(key=lambda x: x[1], reverse=False)82 self.leaders.remove(self.leaders[-1]) ...

Full Screen

Full Screen

s096011846.py

Source:s096011846.py Github

copy

Full Screen

1def main():2 #import sys3 #input = sys.stdin.readline4 n,m = map(int,input().split())5 A = list(map(int,input().split()))6 BC = [list(map(int,input().split())) for _ in range(m)]7 BC = sorted(BC,key=lambda x:(x[1]),reverse=True)8 append_list = []9 for b,c in BC:10 if len(append_list)>=n:11 break12 append_list+=[c]*b13 A+=append_list14 A.sort(reverse=True)15 print(sum(A[:n]))16if __name__=='__main__':...

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 PyHamcrest 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