Here is the deal: i have a website that i want to extract some Href's, especifically the ones that have the text "LEIA ESTA EDIÇÃO", like in this HTML.
<a href="http://acervo.estadao.com.br/pagina/#!/20120824-43410-spo-1-pri-a1-not/busca/ministro+Minist%C3%A9rio" title="LEIA ESTA EDIÇÃO" style="" class="" xpath="1">LEIA ESTA EDIÇÃO</a>
this is the code i have, it's pretty wrong, i was making some tests to see if it work. By the way: It has to be selenium.
driver = webdriver.Chrome()
x = 1
while True:
try:
link = ("http://acervo.estadao.com.br/procura/#!/ministro%3B minist%C3%A9rio|||/Acervo/capa//{}/2000|2010|2010///Primeira").format(x)
driver.get(link)
time.sleep(1)
xpath = "//a[contains(text(),'LEIA ESTA EDIÇÃO')]"
links = driver.find_elements_by_xpath(xpath)
bw=('')
for link in links:
bw += link._element.get_attribute("href")
print (bw)
x = x + 1
time.sleep(1)
except NoSuchElementException:
pass
print(x)
time.sleep(1)