i'm doing "the feeling lucky project" from "automate the boring stuff with python" which i have to open 5 new tabs in the browser based on what you search on google. Using bs4 i managed to get all the links related with search on a list named "links" which looked like this:
and i noticed that before the '#' is the link i actually need, so i tried
for i in links:
if '#' in i:
print(links.index(i))
and i would get index of '#' - 1, so i could get the link. But when i run the code it just prints 1, 1, 1, 1, 1, 1, 1. Which is the index of the first '#' and my loop is stuck there. Can someone explain me why?
Thank you!
Aucun commentaire:
Enregistrer un commentaire