Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97806

Next page on Selenium/Safari

$
0
0

Im trying to do some web-scraping on a site, but I can't access to the next page on safari.

The site is: https://www.emol.com/todas/

the code just give me the same results of the first page twice, I need the first 3st pages

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common import exceptions
from bs4 import BeautifulSoup
import re
import pandas as pd
import os

browser = webdriver.Safari()
browser.get("https://www.emol.com/todas/")

noticias = []
i = 0
while i < 2:
    try:
        nav = browser.find_elements_by_class_name("cont_bus_txt_detall_2")

        for value in nav:
            noticias.append(value.text)

        browser.find_element_by_css_selector("a[href*='javascript:Next();']").click()
        i += 1

    except exceptions.StaleElementReferenceException:
         pass

the below code is when I inspect the button of next page on safari:

<a class="next current-page-next-prev" href="javascript:Next();"><span class="txt_siguiente">Siguiente</span> <i class="fa fa-chevron-right"></i></a>
<span class="txt_siguiente">Siguiente</span>
<i class="fa fa-chevron-right"></I>

enter image description here


Viewing all articles
Browse latest Browse all 97806

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>