Best Python code snippet using SeleniumBase
MovieDB.py
Source:MovieDB.py
...13 def __init__(self, api_key, lingua):14 self.api_key = api_key15 self.lingua = lingua16 self.getGeneros()17 def abrir_url(self, url):18 req = urllib2.Request(url)19 req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')20 response = urllib2.urlopen(req)21 link=response.read()22 response.close()23 return link24 def getGeneros(self):25 url = self.abrir_url('http://api.themoviedb.org/3/genre/movie/list?api_key='+self.api_key)26 soup = json.loads(url)27 for genero in soup["genres"].keys():28 self.generos[genero["id"]] = genero["name"]29 print "GENEROS NOVOS ==========================>"30 print self.generos31 def getMovieInfo(self, idIMDb):32 url = self.abrir_url('https://api.themoviedb.org/3/find/'+idIMDb+'?external_source=imdb_id&language='+self.lingua+'&api_key='+self.api_key)33 soup = json.loads(url)34 print soup35 data = {}36 data["name"] = soup["movie_results"]["original_title"]37 data["poster"] = self.linkImagem+soup["movie_results"]["poster_path"]38 data["genre"] = soup.firstaired.text39 data["plot"] = soup["movie_results"]["overview"]40 return json.dumps(data)41 def getTrailer(self, idIMDb):42 url = self.abrir_url('http://api.themoviedb.org/3/movie/' + idIMDb +'/trailers?api_key=' + self.api_key)43 try:44 data = json.loads(url)45 except:46 data = ''47 try:48 youtube_id = 'plugin://plugin.video.youtube/?action=play_video&videoid=' + str(data['youtube'][0]['source'])49 except:50 youtube_id= ''...
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!!