pagehtml
Version:
A tool to grab and process a website's html.
76 lines (56 loc) • 2.28 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: utils/getLinks.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: utils/getLinks.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* Takes an instance of the JSDOM class and returns all href links.
* @param {jsdom.JSDOM} dom The document object model, an instance of the JSDOM class.
* @returns {Array.<{href: string,
* nodeName: string,
* outerHTML: string,
* innerHTML: string,
* parentElement: string}>}
* links: an array of objects containing relevant link information.
*/
function getLinks(dom) {
let links = Array.prototype.map.call(dom.window.document.querySelectorAll('*[href]'), link =>
{
var linkObject = {};
linkObject.href = link.href;
linkObject.nodeName = link.nodeName.toLowerCase();
linkObject.outerHTML = link.outerHTML;
linkObject.innerHTML = link.innerHTML;
linkObject.parentElement = link.parentElement.nodeName.toLowerCase();
return linkObject
});
return links;
}
module.exports = getLinks;</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="PageHTML.html">PageHTML</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getElementText">getElementText</a></li><li><a href="global.html#getLinks">getLinks</a></li><li><a href="global.html#makeTable">makeTable</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a> on Wed Feb 05 2025 14:23:55 GMT-0800 (Pacific Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>