'Hello, I'm creating this automation with selenium, and I came across this problem
The code is complete and functional but not the way I need it because at this point it ends up collecting all the hrefs with the tag "a" and there are dozens present on the page, but I need you to perform the action in just three. Is there any way to limit the amount?
...enter code here ....
**links_de_posts2 = []
hrefs2 = navegador.find_elements_by_tag_name("a")
pic_hrefs2 = [elem.get_attribute("href") for elem in hrefs2]
print("Encontrei as hrefs!!")
time.sleep(3)
for link in pic_hrefs2:
try:
if link.index("/p/") != -1:
links_de_posts2.append(link)
except:
continue
for pic_href in links_de_posts2:
navegador.get(pic_href)
time.sleep(5)**
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
