#K34227. Extract URLs from HTML

    ID: 25263 Type: Default 1000ms 256MiB

Extract URLs from HTML

Extract URLs from HTML

You are given an HTML document consisting of multiple lines. The document may contain image tags (<img>) and anchor tags (<a>). Your task is to extract all URLs present in the src attribute of <img> tags and the href attribute of <a> tags.

The matching is case-sensitive, meaning that only lowercase tags (<img> and <a>) and their corresponding attributes (src and href) will be considered.

Input Format:

The first line of input contains an integer N denoting the number of lines in the HTML document. The following N lines each contain a part of the HTML content.

Output Format:

Print each extracted URL on a new line in the order they appear in the document. If no URL is found, do not print anything.

inputFormat

The input starts with an integer N (number of lines). This is followed by N lines of HTML content.

outputFormat

Print each extracted URL on a separate line in the order they are found. If there are no URLs, output nothing.## sample

11

  
    Sample HTML
  
  
    

Here is an image:

Image 1

Here is a link:

Visit Page 1
http://example.com/image1.png

http://example.com/page1.html

</p>