I have a list of links and want to select some them based on list of subtrings into the link. I'd like to select the links with the substrings medalha or mencao-honrosa. Following a sample of selected links.
https://onciencias.org/resultado/detalhe/9-ano-ensino-fundamental/medalha-ouro
https://onciencias.org/resultado/detalhe/9-ano-ensino-fundamental/medalha-prata
https://onciencias.org/resultado/detalhe/9-ano-ensino-fundamental/medalha-bronze
https://onciencias.org/resultado/detalhe/9-ano-ensino-fundamental/mencao-honrosa
https://onciencias.org/resultado/detalhe/1-serie/medalha-ouro
https://onciencias.org/resultado/detalhe/1-serie/medalha-prata
https://onciencias.org/resultado/detalhe/1-serie/medalha-bronze
https://onciencias.org/resultado/detalhe/1-serie/mencao-honrosa
https://onciencias.org/resultado/detalhe/2-serie/medalha-ouro
https://onciencias.org/resultado/detalhe/2-serie/medalha-prata
https://onciencias.org/resultado/detalhe/2-serie/medalha-bronze
https://onciencias.org/resultado/detalhe/2-serie/mencao-honrosa
https://onciencias.org/resultado/detalhe/3-serie/medalha-ouro
https://onciencias.org/resultado/detalhe/3-serie/medalha-prata
https://onciencias.org/resultado/detalhe/3-serie/medalha-bronze
https://onciencias.org/resultado/detalhe/3-serie/mencao-honrosa
https://onciencias.org/resultado/detalhe/4-ano-tecnico/medalha-ouro
https://onciencias.org/resultado/detalhe/4-ano-tecnico/medalha-prata
https://onciencias.org/resultado/detalhe/4-ano-tecnico/medalha-bronze
https://onciencias.org/resultado/detalhe/4-ano-tecnico/mencao-honrosa
I did the following code and it's working. What's best another way to write this code and avoid to use or to separate the substrings.
for temp_link in list_links:
if(str(temp_link).find('medalha') != -1 or str(temp_link).find('mencao-honrosa') != -1):
links.append(url_home+temp_link[1:])
print(url_home+temp_link[1:])
Thank you.
in
, it behaves in a way that can seem surprising. For example, if I'm looking for the word'cat'
,'cat' in 'catastrophe'
would return True.