Created
October 14, 2019 18:28
-
-
Save sajjadmd/d85118c658e0fc985c117242a301deee to your computer and use it in GitHub Desktop.
SEO Script, Bing SERP scrap using Chrome Dev Tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function() { | |
| clear(); | |
| const urls = []; | |
| const titles = []; | |
| const descriptions = []; | |
| function uniq(value, index, self) { | |
| return self.indexOf(value) === index; | |
| } | |
| const data = {}; | |
| const u = 'li.b_algo h2 a'; | |
| let found = document.querySelectorAll(u); | |
| if (found.length > 0) { | |
| found.forEach((f) => { | |
| let text = f.href; | |
| if (text) { | |
| urls.push(text); | |
| } else { | |
| urls.push(""); | |
| } | |
| }); | |
| } | |
| const t = 'li.b_algo h2'; | |
| found = document.querySelectorAll(t); | |
| if (found.length > 0) { | |
| found.forEach((f) => { | |
| let text = f.textContent; | |
| if (text) { | |
| titles.push(text); | |
| } else { | |
| titles.push(""); | |
| } | |
| }); | |
| } | |
| const d = 'li.b_algo p'; | |
| found = document.querySelectorAll(d); | |
| if (found.length > 0) { | |
| found.forEach((f) => { | |
| let text = f.textContent; | |
| if (text) { | |
| descriptions.push(text); | |
| } else { | |
| descriptions.push(""); | |
| } | |
| }); | |
| } | |
| const range = n => Array.from(Array(n).keys()); | |
| const result = []; | |
| for (const position of range(urls.length)) { | |
| const url = urls[position]; | |
| const title = titles[position]; | |
| const desc = descriptions[position]; | |
| result.push(`${position+1}\t"${url}"\t"${title}"\t"${desc}"`); | |
| } | |
| const content = "position\turl\ttitle\tdescription\n" + result.join("\n"); | |
| console.log(content); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment