Retrieving CSS content and resolving image references from external CSS files for the Link Validator

Currently, I am developing a Link Validator tool designed to analyze and validate all links within a specific domain based on a given seed page. For instance, when analyzing http://www.example.com/, the tool should assess all links associated with example.com.

The tool is set up to handle four types of files:

  1. Content Pages
  2. Images
  3. CSS
  4. Javascript files

For Content Pages, Images, and Javascript Files, I am utilizing the JSOUP Library. However, I am facing a challenge with CSS files that contain external resources. Specifically, I need a method to extract URL references from selectors like


background-image : url('images.png');
border-image: url('border.png');
and then convert these URLs into absolute URLs. Unfortunately, it appears that the JSOUP library does not offer functionality for handling CSS Selectors and resolving their values as absolute URLs.

While manual string manipulation could be used to solve this issue, it would likely introduce errors. Therefore, I am exploring alternative built-in solutions.

I hope this clarifies my situation. Thank you for your assistance in advance.

Answer №1

Manipulating the string should be relatively simple - just add a slash and the CSS reference to the URL. If there's a "../", you can remove all characters until the next "/". I'm not aware of any pre-built solutions for this, unfortunately. It's also important to prioritize processing images before checking internal links to avoid altering the URL unintentionally.

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

How to Style an Element Based on Fragment Identifier in Href Attribute Using CSS

I've implemented the tabview feature from the YUI3 library. This is how the markup code appears: <div id="demo" class="yui3-tabview-content"> <ul class="yui3-tabview-list"> <li class="yui3-tab yui3-widget yui3-tab-selected"> ...

Deleting multiple items from a gridview all at once can be accomplished using several different

A grid view image gallery app was developed where users can select multiple photos but faced difficulty in deleting all selected images at once due to the design constraints that prevent the use of checkboxes. Can anyone provide suggestions on how to impl ...

Creating a scrolling sidebar in Bootstrap 4

Today I learned about CSS Bootstrap 4 and created my template with a sidebar. However, when there are many menus, I want the sidebar to show a scrollbar. I am looking for help on how to make a scrollbar appear on my sidebar template. Below are my HTML and ...

Creating a Burger Navigation Menu with CSS and HTML using Image Overlapping

I'm encountering an issue with the new website I created for my local Church. I followed a tutorial on building a burger menu using just HTML and CSS, which you can view here. The problem arises when I attempt to place an image below the navigation m ...

What is the best way to create a gap between two Bootstrap buttons?

I'm attempting to create two buttons in the same line in this code, but it's not working as I want. Take a look below: <div class="w3-show-inline-block"> <div class="w3-bar"> <button class="btn btn-s ...

Is it possible to incorporate HTML and CSS into Kivy and Python 3 development?

Currently in the process of creating a multi-touch kivy program using Python 3.52 on Linux. While Kivy is effective, I've encountered challenges with GUI development and experienced laggy animations. I've noticed that my program tends to slow do ...

What is the best way to retrieve an element from an array using a long type index?

Every time I attempt to access an element from an array with a long data type index, I face difficulties. My goal is to retrieve the character at a specific index for comparison with another character. I experimented with the getChar() method of the Arra ...

Having trouble getting the same styles to show up on .class::before and .class::after elements, even though I've applied them. The changes aren't reflecting on the live server

Currently, I am working on a project that involves an ordered list (ol), and I am trying to add pseudo elements (::before,::after) to enhance its appearance. Strangely, when I write ::before and ::after separately, the styles are applied and visible on the ...

Spring Boot @Transactional annotation ensures successful transaction completion

Utilizing spring 4 with spring boot and needing to implement @transactional. Correct me if I'm mistaken - @transactional ensures my function runs in a single transaction with the database. If an error occurs, the function will roll back and no changes ...

Styling for Print Media: Adjusting the horizontal spacing between inline elements

I have been developing a custom AngularJS point-of-sale (POS) system that requires printing receipts upon completing a sale. To achieve this, I am using ng-print to print out a sales summary displayed within a specific div element after hiding all other un ...

What is the best way to transform a CSV file containing both leaf values and hierarchies in each row into JSON using Java?

I have a CSV file with the following structure: Red,Apple,Fruit //(red is the leaf and fruit is the main parent) Orange,Apple,Fruit Pen,Yellow,Mango,Fruit Audi,Car New,Car Sky,Blue,Umbrella The goal is to convert it into a JSON format like this: ...

Contrasting Application and Service in Dropwizard

I'm a newcomer to Dropwizard. It's interesting to note that in the latest documentation, "Service" is mentioned as the main entry point of any application. However, when I looked at the example code, it was using "Application" instead. I presume ...

Change the x and y positions of several div elements as the mouse moves in JavaScript

I am aiming to create a webpage where multiple divs with text and other content move along the x and y axes of the mouse. The desired effect is similar to parallax scrolling, but I have found that existing parallax plugins are image-based and do not work w ...

Tips for creating a more seamless box transition within HTML

I've been searching for information on this topic, but I haven't been able to find a satisfactory answer. I want to create a div that displays "Contact Us" and when clicked, smoothly reveals a layer with input fields. I know I can use JavaScri ...

Comparing the benefits of a 3-column flow layout to a traditional

I've been wondering about the popularity of 3 column flow layouts compared to using a table with 3 columns and one row. Can someone explain the advantages and disadvantages of using a flow layout versus a table layout for this scenario? Thank you ...

Tips for making a background image responsive using ng-style in AngularJS

Can anyone assist me in fixing the gap space issue in a responsive view with an attached jpg background image? Follow this link for more details: enter image description here ...

Steps to click on a link within a span element contained within an anchor element with a specific class using XPath

When using xpath, sélénium is not recognizing the element. What would be the correct xpath to use? HTML: <a class="xmi" onclick="this.focus();return false; "href="#"> <span title="">SITE A</span> </a> XML locator file: <do ...

Tips for replacing all HTML comments in a JSP file with HTML comments in Eclipse

I am tasked with converting all HTML comments in every JSP file in my workspace to JSP comments. The goal is to find all without losing the comments themselves. For example: <!-- I have a comment here --> should be replaced with <%-- I have a c ...

What is the process for creating a modal transition?

I am attempting to add animation to a modal using a transition effect. My goal is to open it slowly, either from the center of the screen or from the bottom. However, I am struggling to understand how this can be achieved... While searching on Google, I c ...

Ways to use CSS to align a table row to the right

I've been attempting to shift the alignment of a table row that contains the navigation links for my website from left to right, but no matter what I try to modify, nothing seems to budge. I'm relatively new to studying HTML and CSS, so I would g ...