Jacksuel,
On the line you order the year, missing close one parentheses:
ano=int(input('Digite o Ano do Filme:'))
After in the get of your zero year if, you have closed two parentheses, you need to remove one:
req=requests.get('https://www.themoviedb.org/search?query='+t+'&language=pt-BR')
Finally, in the get of your LSE, you again closed an extra parenthesis, you need to remove one here too, but in addition to this syntax error, you also wrote twice the req=request.get
, including one within the other, correct as follows:
req=requests.get('https://www.themoviedb.org/search?query='+t+'%20y%3A'+str(ano)+'&language=pt-BR')
Correcting all these points, your code should be more or less as follows:
import requests
from bs4 import BeautifulSoup
t=input('Digite o Nome do Filme:')
ano=int(input('Digite o Ano do Filme:'))
if ano==1:
req=requests.get('https://www.themoviedb.org/search?query='+t+'&language=pt-BR')
bs=BeautifulSoup(req.text, 'lxml')
print(bs.find_all('img'))
else:
req=requests.get('https://www.themoviedb.org/search?query='+t+'%20y%3A'+str(ano)+'&language=pt-BR')
bs=BeautifulSoup(req.text, 'lxml')
print(bs.find_all('img'))
Be careful with the Python spaces, when you corrected the errors I mentioned you gave a space before the IF, this will also generate exceptions.
Use: str(year) in concatenation. Troque req=requests.get(str('https://www.themoviedb.org/search?query='+t+'%20y%3A'+ano+'&language=en-BR')) by req=requests.get('https://www.themoviedb.org/search?query='+t+'%20y%3A'+str(year)+'&language=en-BR')
– anonimo
gave error if ano==0: Syntaxerror: invalid syntax
– Jacksuel Soares Braga
@Jacksuelsoaroarraga I reversed the question because the website format does not contain changes that invalidate the answers are made. Because even the AR (Author of the Answer) striving to solve your problem, if you modify the question the AR runs the risk of being negative even solving part of your problem. Use the comments below the answers to ask for clarifications and updates of the answers. Any questions do our [tour]. If you need to ask a new question, [Ask], and if you need to ask this question as a reference.
– Augusto Vasques