Selenium cant find class to iterate and scrape text

Asked
Active3 hr before
Viewed126 times

7 Answers

iteratescrapeclassselenium
90%

The way of locating a web element we have adopted is unable to identify the desired element as it is not within the browser’s Viewport, ,Selenium works by automating browsers to load the website, retrieve the required data, and even take certain actions on the website

Example_snippet/controller/utility/_iterate.js/ from selenium import webdriver. . .
from selenium
import webdriver

driver = webdriver.Chrome('YOUR_PATH_TO_chromedriver.exe_FILE')
load more v
88%

Example_snippet/controller/utility/_iterate.js/ a = driver.find_elements_by_cl. . .
a = driver.find_elements_by_class_name("content")
load more v
72%

Tools for web scraping like Selenium can scrape a large volume of data such as text and images in a relatively short time,,You can find complete documentation on selenium here

Example_snippet/controller/utility/_iterate.js/ pip install selenium. . .
pip install selenium
load more v
65%

How can Selenium select each div separately that,

Example_snippet/controller/utility/_iterate.js/ List<WebElement> professor. . .
    List<WebElement> professors = driver.findElements(By.className("tile-consultation"));
    ListIterator<WebElement> theListOfProfessors = professors.listIterator();
    Thread.sleep(1000);

    int i = 1;
    while(theListOfProfessors.hasNext()) {
        WebElement professorI = driver.findElement(By.cssSelector(".tile-consultation:nth-of-type(2)"));
        professorI.click();

        Thread.sleep(1000);
        close = driver.findElement(By.cssSelector("button.btn-close"));
        close.click();
        Thread.sleep(1000);
     }
load more v
75%

Line 8 — Note that container1 is a class attribute value identifying two elements and drive,find_element_by_class_name returns the first element found

Example_snippet/controller/utility/_iterate.js/ Element identified by id: Cont. . .
Element identified by id: Content 2 hereElement identified by class: Content hereElement identified by class: Content 3 hereElement identified by tag name: My First HeadingElement identified by xpath: My first paragraph.
Step 2 continued with Content hereContent 3 here. . .
Content hereContent 3 here
load more v
40%

Next we shall get the size of the list with len method, We shall iterate through this list and obtain the text with text method

Example_snippet/controller/utility/_scrape.js/ l=driver.find_elements_by_clas. . .
l = driver.find_elements_by_class_name("gsc-input")
load more v
22%

Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers , Meta Stack Overflow ,Thanks for contributing an answer to Stack Overflow!, Stack Overflow help chat

Example_snippet/controller/utility/_scrape.js/ list_of_ver_links = driver.fin. . .
list_of_ver_links = driver.find_elements(By.XPATH, "//span[contains(text(),'Ver detalle')]/..")
for ver in list_of_ver_links:
   ver.click()
#Now write the code to fetch order details here