Search code examples
htmlweb-scrapingrpauipath

UIPath Data Scraping - Scrape element names


I am trying to scrape this website for concert recommendations. I can easily have UIPath scrape names(1), locations(2) and dates(3) of the concerts (Picture 1), but not their scores (4). enter image description here

I can see from the names of the star elements if they are "on" or "off". Im thinking to use that information to have excel figure out the score later. enter image description here

However, when i try to scrape the stars, UIPath returns empty columns. I guess that is because it cant find any text in these elemtents, which makes total sense. But can I have UIPath to return the names of the star elements in column 4, 5, 6 etc?

enter image description here

Link to website: http://soundvenue.com/musik/anmeldelser

Thank you in advance :)


Solution

  • Like in many cases in RPA there are several possible solutions. You could loop through each individal item and check the number of "on" stars, but if you want to use the Extract Wizard it may be easier to modify the data on the website before extracting rather than after.

    I would try injecting a JavaScript that would append a text to those stars, that would make it easier for RPA extraction.

    Something like this:

    // Get an array of all star containers (span elements with "post-stars" class)
    var ratings = $$("span.post-stars");
    
    // Loop through them
    for (i = 0; i < ratings.length; i++) {
        // Get a number of all stars that are "on"
        var starCount = ratings[i].getElementsByClassName("star-on").length;
    
        // Create a new text node with the star value
        var text = document.createTextNode(starCount);
    
        // Append the text to the star container
        ratings[i].appendChild(text);
    }
    

    The website will then look like this:

    enter image description here