edward-snowden-the-web-crawler

Snowden as we all know is good at stealing and parsing the resources from the internet. He has been threatened by the intelligence agencies to find our parliamentary members for surveillance in one day time. The data would be safe if we are able to collect all the links in a site before him. So our goal is given a webpage source we have to extract all the links going to the same site.

A link will look like this

Note :

The order of links need to be preserved.i.e. the document needs to be scanned from left-right top-bottom fashion.

Input :

The First line is the website name.

Followed by the html content that ends with the string “exit” in a new line.

1 ≤ Length of each line ≤ 500

1 ≤ total number of lines ≤ 25

Output:

Output all the links that links to the same site.

SAMPLE INPUT
http://www.knowyourcandidate.net
<html>
<head>
<title></title>
</head>
<body>
<a href="http://www.knowyourcandidate.net/web/ministers/list/1">List Of Ministers</a>
<a href="http://www.knowyourcandidate.net/mla-tamilnadu">Tamil Nadu MLA's</a>
<a href="http://www.facebook.com/knowurcandidate">Like us on Facebook</a>
<a href="http://plus.google.com/knowyourcandidate">Plus 1 on Google+</a>
</body>
</html>
exit

SAMPLE OUTPUT
http://www.knowyourcandidate.net/web/ministers/list/1
http://www.knowyourcandidate.net/mla-tamilnadu

Explanation

The first Two links, links to the same site www.knowyoucandidate.net whereas the next two links will go to facebook.com and plus.google.com

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: