-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
183 lines (150 loc) · 6.68 KB
/
index.html
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script>
function processarHTML() {
const html = document.getElementById("htmlInput").value;
const div = document.createElement("div");
div.innerHTML = html;
const d = div.querySelector("main");
var filho = div.querySelector("#profile-sticky-header-toggle");
var pai = filho.parentNode;
var perfilid = pai.id;
filho = div.querySelector("#about");
pai = filho.parentNode;
var sobreid = pai.id;
filho = div.querySelector("#experience");
pai = filho.parentNode;
var expid = pai.id;
filho = div.querySelector("#education");
pai = filho.parentNode;
var eduid = pai.id;
filho = div.querySelector("#skills");
pai = filho.parentNode;
var skillid = pai.id;
const perfil = d.querySelector("#"+ perfilid);
const sobre = d.querySelector("#"+sobreid);
const exp = d.querySelector("#" + expid);
const formacao = d.querySelector("#"+eduid);
const competencia = d.querySelector("#"+skillid);
let nomePerfil = "";
let tituloPerfil = "";
const Personal = new cvPessoa();
for (const link of Array.from(perfil.getElementsByTagName("*"))) {
const classe = link.getAttribute("class");
if (classe === "text-heading-xlarge inline t-24 v-align-middle break-words") {
Personal.nome = link.innerText.trim().replace(/[\r\n]/gm, "<br />");
}
if (classe === "text-body-medium break-words") {
Personal.titulo = link.innerText.trim().replace(/[\r\n]/gm, "<br />")
}
}
for (const link of Array.from(sobre.getElementsByTagName("*"))) {
const classe = link.getAttribute("class");
if (classe && classe.includes("inline-show-more-text")) {
Personal.Sobre = link.innerText.trim().replace(/[\r\n]/gm, "<br />");
break;
}
}
const expList = Array.from(exp.querySelector("ul").getElementsByTagName("li"));
for (const link of expList) {
const classe = link.getAttribute("class");
if (link.nodeName === "LI" && classe === "artdeco-list__item pvs-list__item--line-separated pvs-list__item--one-column") {
Personal.expercience.push(new Item());
var items = Array.from(link.querySelectorAll("span"))
for(const per of items)
{
if (per.className === "visually-hidden") {
Personal.expercience[Personal.expercience.length - 1].descricao.push(per.innerText);
}
}
}
}
const formacaoList = Array.from(formacao.querySelector("ul").getElementsByTagName("li"));
for (const link of formacaoList) {
const classe = link.getAttribute("class");
if (link.nodeName === "LI" && classe === "artdeco-list__item pvs-list__item--line-separated pvs-list__item--one-column") {
Personal.formacao.push(new Item());
var items = Array.from(link.querySelectorAll("span"))
for(const per of items)
{
if (per.className === "visually-hidden") {
Personal.formacao[Personal.formacao.length - 1].descricao.push(per.innerText);
}
}
}
}
const competenciaList = Array.from(competencia.querySelector("ul").getElementsByTagName("li"));
for (const link of competenciaList) {
const classe = link.getAttribute("class");
if (link.nodeName === "LI" && classe === "artdeco-list__item pvs-list__item--line-separated pvs-list__item--one-column") {
Personal.competencia.push(new Item());
var items = Array.from(link.querySelectorAll("span"))
for(const per of items)
{
if (per.className === "visually-hidden") {
Personal.competencia[Personal.competencia.length - 1].descricao.push(per.innerText);
}
}
}
}
const jsonStr = JSON.stringify(Personal, null, 2);
console.log(jsonStr);
// Escrever o JSON no HTML
const outputDiv = document.getElementById("output");
const jsonH = document.getElementById("json");
jsonH.value = jsonStr;
outputDiv.innerHTML = "<pre>" + jsonStr.trim().replace(/[\r\n]/gm, "<br />") + "</pre>";
}
class cvPessoa {
constructor() {
this.nome = "";
this.titulo = "";
this.Sobre = "";
this.expercience = [];
this.competencia = [];
this.formacao = [];
}
}
class Item {
constructor() {
this.descricao = [];
}
}
function copiarTexto() {
let textoCopiado = document.getElementById("json");
textoCopiado.select();
//textoCopiado.setSelectionRange(0, 99999)
document.execCommand("copy");
alert("clipboard: " + textoCopiado.value);
}
</script>
</head>
<body>
<h1 class="h1" >Linkedn To Json</h1>
<p class="text-justify" style="font-size: 9pt;"> - Open your linkedn page<br>
- Select language necessary<br>
- with the right button click on inspect<br>
- Copy the source code by selecting HTML<br>
- Paste here<br></p>
<textarea class="textarea" id="htmlInput" rows="10" cols="50" placeholder="Cole ou digite o HTML do linkedn aqui"></textarea>
<br>
<button class="btn btn-info" onclick="processarHTML()">Process</button>
<br><br>
<textarea disabled id="json" value="" placeholder="Result json" rows="10" cols="50"></textarea>
<br>
<button class="btn btn-sucess" onclick="copiarTexto()">Copy to clipboard</button>
<br>
<div id="output"></div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
<footer>
<a href="https://github.com/rafaelparenza/Linkedntojson">Github</a>
</footer>
</html>