Blog
Fiend All URL of website links for making sitemap
# Go to you targeted link, then follow this step stay on this page:
=> if permission not allow, for the permission open Google Chrome Console tab.
Type in Console: allow pasting
Then press Enter
# Narmal way
- Open the Developer Tools: In most web browsers, you can open the developer tools by pressing F12 or by right-clicking on the webpage and selecting "Inspect" or "Inspect Element".
- Navigate to the "Console" Tab: Within the developer tools, you'll typically find several tabs such as "Elements", "Console", "Sources", etc. Click on the "Console" tab to access the JavaScript console.
- Write JavaScript Code: In the console, you can write JavaScript code directly and execute it by pressing Enter. You can manipulate the webpage's DOM, fetch data, and perform various tasks using JavaScript.
Here's an example of how you can extract URLs from a webpage using JavaScript in the browser console. Copy and paste this code into the console, and press Enter to execute it. It will print the URLs of all links on the webpage to the console:
// Find all <a> tags (links) on the webpage
const links = document.querySelectorAll('a');
// Iterate through the links and extract their URLs
links.forEach(link => {
// Get the URL from the href attribute of the <a> tag
const url = link.href;
console.log(url);
});
----
# Others way:
=> Copy this code past Console following JavaScript code and press Enter.
const results = [
['Url', 'Anchor Text', 'External']
];
var urls = document.getElementsByTagName('a');
for (urlIndex in urls) {
const url = urls[urlIndex]
const externalLink = url.host !== window.location.host
if(url.href && url.href.indexOf('://')!==-1) results.push([url.href, url.text, externalLink]) // url.rel
}
const csvContent = results.map((line)=>{
return line.map((cell)=>{
if(typeof(cell)==='boolean') return cell ? 'TRUE': 'FALSE'
if(!cell) return ''
let value = cell.replace(/[\f\n\v]*\n\s*/g, "\n").replace(/[\t\f ]+/g, ' ');
value = value.replace(/\t/g, ' ').trim();
return `"${value}"`
}).join('\t')
}).join("\n");
console.log(csvContent)