-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathURLparse.html
More file actions
98 lines (92 loc) · 2.82 KB
/
URLparse.html
File metadata and controls
98 lines (92 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<html>
<head>
<style>
body, textarea, head, h1, h2, h3, output {
font-family: "Farfetch Basis","Helvetica Neue",Arial,sans-serif;
color:white;
background-color: black;
}
.button-1 {
background-color: #222;
border-radius: 4px;
border-style: none;
box-sizing: border-box;
color: #fff;
cursor: pointer;
display: inline-block;
font-family: "Farfetch Basis","Helvetica Neue",Arial,sans-serif;
font-size: 16px;
font-weight: 700;
line-height: 1.5;
margin: 0;
max-width: none;
min-height: 44px;
min-width: 10px;
outline: none;
overflow: hidden;
padding: 9px 20px 8px;
position: relative;
text-align: center;
text-transform: none;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
width: 25%;
}
.button-1:hover,
.button-1:focus {
opacity: .75;
}
</style>
<h1> URL Extractor </h1>
</head>
<body>
<h3>Enter your text below to extract the URLs</h3>
<textarea id="input" rows="20" style="width: 50%" ></textarea>
<br><br>
<button class="button-1" onclick="parseInput()">Submit</button>
<button class="button-1" onclick="clearInput()">Clear</button>
<br>
<div id="output"></div>
<button class="button-1" onclick="copyToClipboard()">Copy</button>
</body>
<script>
function parseInput() {
// Get the user input from the text box
var input = document.getElementById("input").value;
// Split the input into separate lines
var lines = input.split("\n");
// Initialize an array to store the URLs
var urls = [];
// Iterate over each line
for (var i = 0; i < lines.length; i++) {
// Use a regular expression to match URLs
var match = lines[i].match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9]{1,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/);
// If a URL was found, add it to the array of URLs
if (match) {
urls.push(match[0]);
}
}
// Display the URLs on the page
var output = "";
for (var i = 0; i < urls.length; i++) {
output += "<p>" + urls[i] + "</p>";
}
document.getElementById("output").innerHTML = output;
}
function clearInput() {
document.getElementById("input").value = "";
document.getElementById("output").innerHTML = "";
}
function copyToClipboard() {
var outputElement = document.getElementById("output");
var range = document.createRange();
range.selectNode(outputElement);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
document.execCommand("copy");
window.getSelection().removeAllRanges();
alert("Links copied to clipboard!");
}
</script>
</html>