How can you retrieve a list of hyperlinks from a webpage based solely on the color of the associated images?

Is it possible to use Selenium Webdriver to fetch a list of hyperlinks on a webpage with red/green color bullets based on user-provided IP data? These hyperlinks are generated dynamically. For example, when a user visits and enters a specific IP address, I need to extract hyperlinks with green and red colors separately. Can this task be automated using webdriver?

Here is the current script:

public class SelectCategory extends Config {

    public static WebDriver driver;

    @Test(enabled = true)

    public void Blacklist1() throws IOException {

        Properties p = new Properties(GetDataFromFile());

        System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
        driver = new FirefoxDriver();
        driver.get(p.getProperty("BLURL"));

        WebElement D1 = driver.findElement(By.xpath(".//*[@id='quickcheck']/input[1]"));
        D1.clear();
        D1.sendKeys(p.getProperty("IP1"));

        WebElement D2 = driver.findElement(By.xpath(".//*[@id='quickcheck']/input[2]"));
        D2.click();

    }

    public Properties GetDataFromFile() throws IOException {
        File F = new File("*Path of properties file");
        FileInputStream fis = new FileInputStream(F);
        Properties prop = new Properties();
        prop.load(fis);
        return prop;
    }
}

Answer №1

To tackle this problem, one potential solution (though not the most efficient in my view) is to extract and store the img src links of each IP address by scraping them, followed by sequentially clicking on each individual img src link.

After each click, it will be necessary for you to determine the current URL (which will indicate the color of the IP). Here's an illustration showcasing the element of one of the IP color balls:

<img height="15" width="15" src="http://www1.dnsbl.info/test-a.php?bl=bl.emailbasura.org&ip=208.87.233.201&cb=1123477419&token=0f46ad74b3eb0606dc4644be7218d0d5" alt="">

The key step involves extracting the actual URL from the variable "src."

A green image will exhibit a URL similar to:
Any URL deviating from this format will not be categorized as green.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a drop-down menu within an HTML table along with a D3 bar chart

How can I implement a drop-down menu allowing the user to choose a time interval for this HTML table and d3 bar chart? The time intervals needed are: Now, 24 hours, 48 hours, 72 hours, 1 week, and 1 month. I am relatively new to creating dynamic tables and ...

CKEditor displays the HTML content as regular text

After using CK editor to store HTML data in the database successfully, I am encountering an issue where the saved HTML content appears as plain text when viewed. Here is an example: &lt;div class=&quot;testimg&quot;&gt; Legion of Honor Mu ...

django was unable to interpret the remainder: 'css/materialize.min.css' from 'css/materialize.min.css'

In following a tutorial, I am adding a chat bot UI that is embedded in Django. The file structure looks like this: . ├── db.sqlite3 ├── installDjango.sh ├── manage.py ├── rasadjango │ ├── asgi.py │ ├── __init__.p ...

What is the best way to ensure that a css grid using grid-template-columns: repeat(auto-fit, minmax(x,y)) distributes items as evenly as possible across each row?

I'm in the process of creating a CSS grid. Here is a snippet of the CSS I am using: div.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); } Within my HTML code, there are exactly 6 items: <div class=st ...

The design became distorted when the fonts were resized in every browser

Looking for assistance with a simple layout issue. When I scale the font in browsers by using CTRL and scrolling up (zooming), the layout does not behave as expected. I want #allWrapper to scale its dimensions with the body so that the white background ex ...

Is there a way for me to determine when the modal animation has completed?

I'm currently using the modal feature in twitter-bootstrap and I am curious about how long it takes for the modal to appear before triggering an alert. To better illustrate my point, you can check out this example: HTML <button id="mod" class="b ...

creating unique styles for your Ionic app with Angular using JSON

Having trouble changing the item color. Does anyone know why my CSS isn't working, or if I'm missing something? <ion-view title="Add order to a table"> <ion-content class="has-header has-subheader"> <ion-list> ...

Issues with Bootstrap Carousel Fade Transition and Button Controls inoperable

I am currently exploring the creation of a carousel on bootstrap that transitions smoothly between three images (specifically 3 'gorilla' jpgs). However, I am encountering some challenges while learning HTML. Challenge 1: The carousel is not tra ...

Prevent the input from escaping the container

I am facing an issue with my form where I want the input field to expand only up to the end of the container div, but it seems to extend beyond due to the length of the pre-input text. .container { width: 70%; } .input-field { display: inline-block; ...

selenium script for extracting information from excel document

I am currently working on a Selenium script that extracts data from an Excel file and then enters that data into a website's text box. The code is successfully fetching and storing the data in an object array, but I'm encountering an error when t ...

Why do all the select boxes require two clicks to open the drop-down menu when the function is activated?

After implementing this code on my webpage, I noticed an issue where all select boxes required two clicks from the user to open the drop-down menu. The first click seemed to set focus on the box, and only on the second click would the drop-down actually ap ...

Struggle with Arranging Elements in CSS using position absolute & relative

Currently tackling a project involving adjusting the positioning of elements within a sidebar. The sidebar holds Font Awesome icons and corresponding text elements, with the goal of moving both the icons and text together as one unit using attribute and cl ...

Is the z-index problem in Safari related to a transform issue?

I've tried different solutions for similar issues, but I'm struggling to get the text to appear properly on my custom buttons in Safari. They are displaying perfectly in Chrome and Firefox, but not on iOS devices. Does anyone have any suggestion ...

random identifier selection using selenium's xpath and css selector algorithm

Hello, I am a newcomer to using Selenium with Python. I am facing an issue where the id, xpath, and css selector contain random values each time I navigate to the page. I have tried using various methods like xpath, id, css selector, and even class name to ...

Easy selector for choosing jquery css backgrounds

Here is a simple background selector that I created. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <hea ...

Selenium in combination with Python anticipates a particular element that has already been located

I'm having trouble using the expect method on an object that is already located. The issue arises when I try to interact with the element after it has been clicked, as it mutates into one of many similar input elements and can only be distinguished by ...

The placement is based on its relative position within the table row layout

I am trying to create a table using div elements styled with table CSS. One of the rows contains an absolutely positioned div, but setting position:relative; on the row element doesn't work as expected. Here is my table layout without attempting to l ...

Is there a way to make a glossy `selectInput()` extend beyond a `bslib::navset_card_pill()`?

The dilemma: My issue is that the selectInput() in my code gets cut off by the lower border of the card: library(shiny) # Version 1.7.4 library(bslib) # Version 0.5.0 ui <- page_fluid( navset_card_pill(nav_panel( title = "No overflow :(&quo ...

Uncovering Concealed Elements in Selenium Framework

I've been struggling to figure out why the code below isn't working. My goal is to input a key into a search field on a different tab of a website and then click a button. I suspect that the element may be hidden or wrapped based on similar quest ...

The non-disappearing nature of -webkit-appearance

I have been attempting to eliminate the -webkit-appearance:none; property using jQuery, but all my efforts have been unsuccessful. Here are the methods I have tried: jQuery(document).ready(function(){ jQuery("select").removeAttr('style'); j ...