How to use get_movie_info method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

app.py

Source:app.py Github

copy

Full Screen

...19 movie_id = df.iloc[i[0]].id20 recommended_movies.append(df.iloc[i[0]].title)21 recommended_movies_poster.append(get_poster(movie_id, base_url))22 return recommended_movies, recommended_movies_poster23def get_movie_info(name, movie_df):24 movie_df2 = movie_df[['title', 'director', 'genres', 'cast', 'release_date', 'runtime']]25 st.sidebar.subheader('Title:')26 st.sidebar.write(movie_df2[movie_df2['title'] == name].iloc[0,0])27 st.sidebar.subheader('Director:')28 st.sidebar.write(movie_df2[movie_df2['title'] == name].iloc[0,1])29 st.sidebar.subheader('Genres:')30 st.sidebar.write(movie_df2[movie_df2['title'] == name].iloc[0,2])31 st.sidebar.subheader('Cast:')32 st.sidebar.write(movie_df2[movie_df2['title'] == name].iloc[0,3])33 st.sidebar.subheader('Release_date:')34 st.sidebar.write(movie_df2[movie_df2['title'] == name].iloc[0,4])35 st.sidebar.subheader('Runtime:')36 st.sidebar.write(str(movie_df2[movie_df2['title'] == name].iloc[0,5]))37########################38# base url tmdb api39base_url = 'https://api.themoviedb.org/3/movie/'40# import final dataset41movie_df = pickle.load(open('movies_df.pkl', 'rb'))42movie_df = pd.DataFrame(movie_df)43# get titoli film44titles = movie_df['title'].values45# import similarity matrix46similarity_matrix = pickle.load(open('similarity_matrix.pkl', 'rb'))47# titolo pagina48st.title('Movie Recommendation App')49# box selezione film50selected_film = st.selectbox(51'Insert a film name',52titles53)54# bottone raccomandazioni55if st.checkbox('Recommend'):56 # lista 10 raccomandazioni + chiamata api poster57 recommended_movies, recommended_movies_poster = get_recommandations(selected_film, movie_df, similarity_matrix, base_url)58 # 2 righe con 5 film + bottone informazioni per singolo film59 col1, col2, col3, col4, col5 = st.columns(5)60 with col1:61 check1 = st.button('Info 1')62 if check1:63 get_movie_info(recommended_movies[0], movie_df)64 st.write(recommended_movies[0])65 st.image(recommended_movies_poster[0])66 67 with col2:68 check2 = st.button('Info 2')69 if check2:70 get_movie_info(recommended_movies[1], movie_df)71 st.write(recommended_movies[1])72 st.image(recommended_movies_poster[1])73 74 with col3:75 check3 = st.button('Info 3')76 if check3:77 get_movie_info(recommended_movies[2], movie_df)78 st.write(recommended_movies[2])79 st.image(recommended_movies_poster[2])80 with col4:81 check4 = st.button('Info 4')82 if check4:83 get_movie_info(recommended_movies[3], movie_df)84 st.write(recommended_movies[3])85 st.image(recommended_movies_poster[3])86 with col5:87 check5 = st.button('Info 5')88 if check5:89 get_movie_info(recommended_movies[4], movie_df) 90 st.write(recommended_movies[4])91 st.image(recommended_movies_poster[4])92 col6, col7, col8, col9, col10 = st.columns(5)93 with col6:94 check6 = st.button('Info 6')95 if check6:96 get_movie_info(recommended_movies[5], movie_df) 97 st.write(recommended_movies[5])98 st.image(recommended_movies_poster[5])99 with col7:100 check7 = st.button('Info 7')101 if check7:102 get_movie_info(recommended_movies[6], movie_df)103 st.write(recommended_movies[6])104 st.image(recommended_movies_poster[6])105 with col8:106 check8 = st.button('Info 8')107 if check8:108 get_movie_info(recommended_movies[7], movie_df) 109 st.write(recommended_movies[7])110 st.image(recommended_movies_poster[7])111 with col9:112 check9 = st.button('Info 9')113 if check9:114 get_movie_info(recommended_movies[8], movie_df)115 st.write(recommended_movies[8])116 st.image(recommended_movies_poster[8])117 with col10:118 check10 = st.button('Info 10')119 if check10:120 get_movie_info(recommended_movies[9], movie_df)121 st.write(recommended_movies[9])122 st.image(recommended_movies_poster[9])123 ...

Full Screen

Full Screen

s_person.py

Source:s_person.py Github

copy

Full Screen

...32 'scrap_date',33 ],34 }35 36 def get_movie_info(self, r):37 if not r:38 return "-"39 movies = []40 links = r.css('li a::attr(href)').extract()41 for l in links:42 if l.find('/movie/') > 0:43 movies.append(l.split('/')[-2])44 45 return movies46 47 def parse(self, response):48 49 if response.status == 404:50 print("id ", self.curr_page , "not found")51 if self.curr_page < self.max_page:52 self.curr_page += 1 53 next_page_url = "https://www.bmdb.com.bd/person/" + str(self.curr_page) + "/"54 yield scrapy.Request(url=next_page_url, callback=self.parse)55 return56 57 58 item = {}59 60 item['id'] = self.curr_page61 item['scrap_date'] = datetime.today().strftime('%Y-%m-%d %H:%M')62 item['name'] = clean_result(response.css('.entry-title::text').extract_first(),None,'-',True)63 item['description'] = clean_result(response.css('.entry-content').extract_first())64 details_table = []65 for row in response.xpath('//*[@class="table"]//tr'):66 details_table.append({67 'i': row.xpath('td[1]//text()').extract_first(),68 'v': row.xpath('td[2]//text()').extract_first(),69 })70 item['details_table'] = details_table71 item['profile_pic'] = response.css(72 '#sidebar-left .wp-post-image::attr(src)').extract_first()73 74 images = response.css(75 '.thumbnails li a::attr(href)').extract()76 77 if images is None:78 item['images'] = "-"79 elif len(images) > 0:80 picked_images = []81 82 for i in images:83 if i.startswith('/person'):84 continue85 else:86 picked_images.append(i)87 item['images'] = json.dumps(picked_images)88 else:89 item['images'] = "-"90 91 92 item['acting'] = self.get_movie_info(response.css('#acting'))93 item['direction'] = self.get_movie_info(response.css('#direction'))94 item['writer'] = self.get_movie_info(response.css('#writer'))95 item['art'] = self.get_movie_info(response.css('#art'))96 item['choreographer'] = self.get_movie_info(response.css('#choreographer'))97 item['producer_person'] = self.get_movie_info(response.css('#producer_person'))98 item['lyricist'] = self.get_movie_info(response.css('#lyricist'))99 item['singer'] = self.get_movie_info(response.css('#singer'))100 101 print(item['id'],"/",self.max_page,' - ',item['name'])102 yield item103 if self.curr_page < self.max_page:104 self.curr_page += 1 105 next_page_url = "https://www.bmdb.com.bd/person/" + str(self.curr_page) + "/"...

Full Screen

Full Screen

03_肝个案例.py

Source:03_肝个案例.py Github

copy

Full Screen

...7 s = "".join(lst)8 return s.strip()9 else:10 return ""11def get_movie_info(year):12 # 抓取1996年的电影票房13 f = open(f"{year}.csv", mode="w", encoding="utf-8")14 url = f"http://www.boxofficecn.com/boxoffice{year}"15 headers = {16 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"17 }18 resp = requests.get(url, headers=headers)19 tree = etree.HTML(resp.text)20 trs = tree.xpath("//table/tbody/tr")[1:]21 for tr in trs:22 num = tr.xpath("./td[1]//text()")23 year = tr.xpath("./td[2]//text()")24 name = tr.xpath("./td[3]//text()")25 money = tr.xpath("./td[4]//text()")26 num = str_tools(num) # ???27 year = str_tools(year) # ???28 name = str_tools(name) # ???29 money = str_tools(money) # ???30 f.write(f"{num},{year},{name},{money}\n")31if __name__ == '__main__':32 # s1 = time.time() # 当前系统时间的时间戳33 # for y in range(1994, 2023):34 # get_movie_info(y)35 # s2 = time.time() # 执行之后的时间戳36 # print(s2 - s1) # 16.2337 # 效果不够好. 有丢失数据现象.这个网站不能直接这么干. 需要数据的验证或者单线程.38 s1 = time.time()39 with ThreadPoolExecutor(20) as t:40 for y in range(1994, 2023):41 t.submit(get_movie_info, y) # 交任务42 s2 = time.time()...

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