How to use contained method in localstack

Best Python code snippet using localstack_python

base_judge.py

Source:base_judge.py Github

copy

Full Screen

...5class BaseJudge(Base):6 def is_video(self, p):7 try:8 # 央广网(中国广播网)9 if tools.judge_url_contained('cnr', p._url):10 p.set_website(cnr.CNR())11 result = p.is_video()12 if result:13 return True14 # 中国网络电视台(CNTV)15 elif tools.judge_url_contained('cctv', p._url):16 p.set_website(cctv.CCTV())17 result = p.is_video()18 if result:19 return True20 # 国际在线21 elif tools.judge_url_contained('cri', p._url):22 p.set_website(cri.CRI())23 result = p.is_video()24 if result:25 return True26 # 人民网27 elif tools.judge_url_contained('people', p._url):28 p.set_website(people.People())29 result = p.is_video()30 if result:31 return True32 # 新华网33 elif tools.judge_url_contained('xinhuanet', p._url):34 p.set_website(xinhua.XinHua())35 result = p.is_video()36 if result:37 return True38 # 中国军网39 elif tools.judge_url_contained('81', p._url):40 p.set_website(military.Military())41 result = p.is_video()42 if result:43 return True44 # 光明网45 elif tools.judge_url_contained('gmw', p._url):46 p.set_website(gmw.Gmw())47 result = p.is_video()48 if result:49 return True50 # 中国经济网51 elif tools.judge_url_contained('ce', p._url):52 p.set_website(ce.Ce())53 result = p.is_video()54 if result:55 return True56 # 中国日报网57 elif tools.judge_url_contained('chinadaily', p._url):58 pass59 # 人民政协网60 elif tools.judge_url_contained('rmzxb', p._url):61 pass62 # 环球网63 elif tools.judge_url_contained('huanqiu', p._url):64 p.set_website(huanqiu.HuanQiu())65 result = p.is_video()66 if result:67 return True68 # 中国青年网69 elif tools.judge_url_contained('youth', p._url):70 p.set_website(youth.Youth())71 result = p.is_video()72 if result:73 return True74 # 中青在线75 elif tools.judge_url_contained('cyol', p._url):76 p.set_website(cyol.Cyol())77 result = p.is_video()78 if result:79 return True80 # 法制网81 elif tools.judge_url_contained('legaldaily', p._url):82 p.set_website(legaldaily.Legaldaily())83 result = p.is_video()84 if result:85 return True86 # 中华女性网(暂未发现)87 elif tools.judge_url_contained('cnwomen', p._url):88 pass89 # 中国农业新闻网90 elif tools.judge_url_contained('farmer', p._url):91 p.set_website(farmer.Farmer())92 result = p.is_video()93 if result:94 return True95 # 中国科技网96 elif tools.judge_url_contained('stdaily', p._url):97 p.set_website(stdaily.Stdaily())98 result = p.is_video()99 if result:100 return True101 # 海外网102 elif tools.judge_url_contained('haiwainet', p._url):103 p.set_website(haiwainet.HaiWai())104 result = p.is_video()105 if result:106 return True107 # 中工网(网站迁移http://www.workercn.cn/)108 # 视频少109 elif tools.judge_url_contained('workercn', p._url):110 pass111 # 党建网112 elif tools.judge_url_contained('dangjian', p._url):113 p.set_website(dangjian.DangJian())114 result = p.is_video()115 if result:116 return True117 # 中国网118 elif tools.judge_url_contained('china', p._url):119 p.set_website(china.China())120 result = p.is_video()121 if result:122 return True123 # 中新网(中国新闻网)124 elif tools.judge_url_contained('chinanews', p._url):125 p.set_website(chinanews.ChinaNews())126 result = p.is_video()127 if result:128 return True129 # 虎嗅网(视频暂未发现)130 elif tools.judge_url_contained('huxiu', p._url):131 pass132 # 未来网133 elif tools.judge_url_contained('k618', p._url):134 p.set_website(weilai.WeiLai())135 result = p.is_video()136 if result:137 return True138 # 北京时间(新闻数据和视频都不在源码中)139 elif tools.judge_url_contained('brtn', p._url):140 pass141 # 驱动中国142 elif tools.judge_url_contained('qudong', p._url):143 p.set_website(qudong.QuDong())144 result = p.is_video()145 if result:146 return True147 # 东海网148 elif tools.judge_url_contained('dhtv', p._url):149 p.set_website(dhtv.Dhtv())150 result = p.is_video()151 if result:152 return True153 # 比特网(暂未找到视频)154 elif tools.judge_url_contained('chinabyte', p._url):155 pass156 # 每经网(暂未找到视频)157 elif tools.judge_url_contained('nbd', p._url):158 pass159 # 中国文明网160 elif tools.judge_url_contained('wenming', p._url):161 p.set_website(wenming.WenMing())162 result = p.is_video()163 if result:164 return True165 # 凤凰网166 elif tools.judge_url_contained('ifeng', p._url):167 p.set_website(fenghuang.Ifeng())168 result = p.is_video()169 if result:170 return True171 # 新浪172 elif tools.judge_url_contained('sina', p._url):173 p.set_website(sina.Sina())174 result = p.is_video()175 if result:176 return True177 # 搜狐178 elif tools.judge_url_contained('sohu', p._url):179 p.set_website(souhu.SouHu())180 result = p.is_video()181 if result:182 return True183 # 网易网184 elif tools.judge_url_contained('163', p._url):185 p.set_website(wangyi.WangYi())186 result = p.is_video()187 if result:188 return True189 # 百度新闻190 elif tools.judge_url_contained('baidu', p._url):191 pass192 # 猫扑193 elif tools.judge_url_contained('mop', p._url):194 pass195 # 澎湃网196 elif tools.judge_url_contained('thepaper', p._url):197 p.set_website(thepaper.Thepaper())198 result = p.is_video()199 if result:200 return True201 # 腾讯网202 elif tools.judge_url_contained('qq', p._url):203 p.set_website(qq.QQ())204 result = p.is_video()205 if result:206 return True207 # 中国新闻出版广电网208 elif tools.judge_url_contained("chinaxwcb", p._url):209 pass210 # 国家广播电视总局211 elif tools.judge_url_contained("nrta", p._url):212 pass213 # 东方网214 elif tools.judge_url_contained("eastday", p._url):215 p.set_website(eastday.EastDay())216 result = p.is_video()217 if result:218 return True219 elif tools.judge_url_contained("cm3721", p._url):220 pass221 # 上观网222 elif tools.judge_url_contained("shobserver", p._url):223 pass224 # 新京报网225 elif tools.judge_url_contained("bjnews", p._url):226 p.set_website(bjnews.BjNews())227 result = p.is_video()228 if result:229 return True230 else:231 return False232 except Exception:...

Full Screen

Full Screen

judge_website_name.py

Source:judge_website_name.py Github

copy

Full Screen

1import re2from urllib import parse3def judge_url_contained(keyword,url):4 '''5 :param keyword: 域名6 :param url: 网站地址7 :return: 判断这个域名是否隶属于这个网站8 '''9 result = parse.urlparse(url)[1]10 try:11 domain=re.search(r"\.(.*)\.",result).group(1)12 except Exception as e:13 end=result.rfind(".")14 domain=result[:end]15 if "." in domain:16 str_list=domain.split(".")17 for domain in str_list:18 if keyword in domain:19 if len(keyword)==len(domain):20 return True21 else:22 return False23 else:24 continue25 else:26 if keyword in domain:27 if len(keyword)==len(domain):28 return True29 else:30 return False31 else:32 return False33def get_website_name(root_url):34 try:35 #央广网(中国广播网)36 if judge_url_contained('cnr',root_url):37 return '央广网'38 #中国网络电视台(CNTV)39 elif judge_url_contained('cctv',root_url):40 return '中国网络电视台'41 #国际在线42 elif judge_url_contained('cri',root_url):43 return '国际在线'44 #人民网45 elif judge_url_contained('people',root_url):46 return '人民网'47 #新华网48 elif judge_url_contained('xinhuanet',root_url):49 return '新华网'50 #求是网51 elif judge_url_contained('qstheory',root_url):52 return '求是网'53 #中国军网54 elif judge_url_contained('81',root_url):55 return '中国军网'56 #光明网57 elif judge_url_contained('gmw',root_url):58 return '光明网'59 #中国经济网60 elif judge_url_contained('ce',root_url):61 return '中国经济网'62 #中国日报网63 elif judge_url_contained('chinadaily',root_url):64 return '中国日报网'65 #人民政协网66 elif judge_url_contained('rmzxb',root_url):67 return '人民政协网'68 #环球网69 elif judge_url_contained('huanqiu',root_url):70 return '环球网'71 #中国青年网(暂未发现相关视频板块)72 elif judge_url_contained('youth',root_url):73 return '中国青年网'74 #中青在线75 elif judge_url_contained('cyol',root_url):76 return '中青在线'77 #法制网78 elif judge_url_contained('legaldaily',root_url):79 return '法制网'80 #中华女性网(暂未发现)81 elif judge_url_contained('cnwomen',root_url):82 return '中华女性网'83 #中国农业新闻网84 elif judge_url_contained('farmer',root_url):85 return '中国农业新闻网'86 #中国科技网87 elif judge_url_contained('stdaily',root_url):88 return '中国科技网'89 #海外网90 elif judge_url_contained('haiwainet',root_url):91 return '海外网'92 #中工网(网站迁移http://www.workercn.cn/)93 #视频少94 elif judge_url_contained('workercn',root_url):95 return '中工网'96 #党建网97 elif judge_url_contained('dangjian',root_url):98 return '党建网'99 #中华网100 elif judge_url_contained('china',root_url):101 return '中华网'102 #中新网(中国新闻网)103 elif judge_url_contained('chinanews',root_url):104 return '中国新闻网'105 #虎嗅网(视频暂未发现)106 elif judge_url_contained('huxiu',root_url):107 return '虎嗅网'108 # #Techweb(外链优酷视频)109 elif judge_url_contained('techweb',root_url):110 return 'Techweb'111 #中公教育(pass)112 elif judge_url_contained('offcn',root_url):113 return '中公教育'114 #未来网115 elif judge_url_contained('k618',root_url):116 return '未来网'117 #北京时间(新闻数据和视频都不在源码中)118 elif judge_url_contained('brtn',root_url):119 return '北京时间'120 #驱动中国121 elif judge_url_contained('qudong',root_url):122 return '驱动中国'123 #观察者124 elif judge_url_contained('guancha',root_url):125 return '观察者'126 #东海网127 elif judge_url_contained('dhtv',root_url):128 return '东海网'129 #比特网(暂未找到视频)130 elif judge_url_contained('chinabyte',root_url):131 return '比特网'132 #每经网(暂未找到视频)133 elif judge_url_contained('nbd',root_url):134 return '每经网'135 #中国文明网136 elif judge_url_contained('wenming',root_url):137 return '中国文明网'138 #凤凰网139 elif judge_url_contained('ifeng',root_url):140 return '凤凰网'141 #新浪142 elif judge_url_contained('sina',root_url):143 return '新浪网'144 #搜狐145 elif judge_url_contained('sohu',root_url):146 return '搜狐网'147 #网易网148 elif judge_url_contained('163',root_url):149 return '网易网'150 #百度新闻151 elif judge_url_contained('baidu',root_url):152 return '百度新闻'153 #猫扑154 elif judge_url_contained('mop',root_url):155 return '猫扑'156 #搜狐博客157 elif judge_url_contained('souhu',root_url):158 return '搜狐网'159 #澎湃网160 elif judge_url_contained('thepaper',root_url):161 return '澎湃网'162 #腾讯网163 elif judge_url_contained('qq',root_url):164 return '腾讯网'165 #中国新闻出版广电网166 elif judge_url_contained("chinaxwcb",root_url):167 return '中国新闻出版广电网'168 #国家广播电视总局169 elif judge_url_contained("nrta",root_url):170 return '国家广播电视总局'171 #东方网172 elif judge_url_contained("eastday", root_url):173 return '国家广播电视总局'174 elif judge_url_contained("cm3721", root_url):175 return ''176 #上观网177 elif judge_url_contained("jfdaily", root_url):178 return '上观网'179 #新京报网180 elif judge_url_contained("bjnews", root_url):181 return '新京报网'182 #天涯网183 elif judge_url_contained('tianya', root_url):184 return '天涯网'185 #电子商务研究中心186 elif judge_url_contained('100ec',root_url):187 return '电子商务研究中心'188 else:189 return ''190 except Exception:191 return ''192if __name__ == '__main__':193 url = 'http://www.100ec.cn/detail--6258283.html%20'194 name = get_website_name(url)...

Full Screen

Full Screen

script.py

Source:script.py Github

copy

Full Screen

1from random import randint2from Cores import cores3import pandas as pd4for j in range(800):5 df = pd.read_csv("coin_flip_results.csv")6 six = df['Times 6 streak appeared']7 seven = df['Times 7 streak appeared']8 eight = df['Times 8 streak appeared']9 nine = df['Times 9 streak appeared']10 ten = df['Times 10 streak appeared']11 coin_side = ['Heads', 'Tails']12 streak_count = 113 previous_flip = ' '14 def checking_streaks(number_of_streaks, number:int, streak_count,contained_six, count=0):15 if streak_count >= number:16 number_of_streaks += 1 17 count += 118 if count >0:19 contained_six += 120 return number_of_streaks, contained_six21 def applying_color(new_flip):22 if new_flip == 'Heads':23 color = '\033[31m'24 else:25 color = '\033[32m'26 return color27 def percentage_calculator(number_of_streaks,contained, total = df['Total games played']):28 if number_of_streaks > 0:29 contained += 130 percentage = ((contained/total) * 100).round(2)31 return percentage, contained32 # SCRIPT33 contained_six=contained_seven=contained_eight=contained_nine=contained_ten=0 #variable made to verify if a game contained a certain amount of streak34 # 200 coin toss sequence35 for i in range(200):36 new_flip = coin_side[randint(0,1)]37 color = applying_color(new_flip)38 if new_flip == previous_flip:39 streak_count += 140 else:41 streak_count = 142 print(f'{streak_count} {color}{new_flip}', cores('nula'))43 previous_flip = new_flip44 six, contained_six = checking_streaks(six, 6, streak_count, contained_six)45 seven, contained_seven = checking_streaks(seven, 7, streak_count, contained_seven)46 eight, contained_eight = checking_streaks(eight, 8, streak_count, contained_eight)47 nine, contained_nine = checking_streaks(nine, 9, streak_count, contained_nine)48 ten, contained_ten = checking_streaks(ten, 10, streak_count, contained_ten)49 df['Total games played'] += 150 # Calculating percentages and averages51 df['Contained a 6 streak %'], df['Contained a 6 streak'] = percentage_calculator(contained_six, df['Contained a 6 streak'])52 df['Contained a 7 streak %'], df['Contained a 7 streak'] = percentage_calculator(contained_seven, df['Contained a 7 streak'])53 df['Contained a 8 streak %'], df['Contained a 8 streak'] = percentage_calculator(contained_eight, df['Contained a 8 streak'])54 df['Contained a 9 streak %'], df['Contained a 9 streak'] = percentage_calculator(contained_nine, df['Contained a 9 streak'])55 df['Contained a 10 streak %'], df['Contained a 10 streak'] = percentage_calculator(contained_ten, df['Contained a 10 streak'])56 df["6 streak average"] = (df['Times 6 streak appeared'] / df ['Total games played']).round(2)57 df["7 streak average"] = (df['Times 7 streak appeared'] / df ['Total games played']).round(2)58 df["8 streak average"] = (df['Times 8 streak appeared'] / df ['Total games played']).round(2)59 df["9 streak average"] = (df['Times 9 streak appeared'] / df ['Total games played']).round(2)60 df["10 streak average"] = (df['Times 10 streak appeared'] / df ['Total games played']).round(2)61 df = df[["Times 6 streak appeared","Contained a 6 streak", "Contained a 6 streak %",'6 streak average','Times 7 streak appeared','Contained a 7 streak','Contained a 7 streak %','7 streak average','Times 8 streak appeared','Contained a 8 streak','Contained a 8 streak %','8 streak average','Times 9 streak appeared','Contained a 9 streak','Contained a 9 streak %','9 streak average','Times 10 streak appeared','Contained a 10 streak','Contained a 10 streak %','10 streak average','Total games played']]62 df.to_csv("coin_flip_results.csv", index=False)...

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