Urgent.News

What's breaking now, across thousands of outlets.

Tech

Internal linking as a data structure

Internal linking as a data structure Most internal linking work happens by hand: an editor remembers a related page and drops a link at the bottom of a post. That works until the site passes a few hundred URLs, at which point nobody remembers what links to what, and pages start going dark without anyone noticing. The fix is to stop treating internal links as content and start treating them as a…

Internal linking functions as a data structure within websites. Initially, editors manually insert links, which becomes unwieldy as the site grows. To address this, internal links should be treated as a graph, where each URL is a node and 'a href' pointing to another URL on the same domain is a directed edge. This allows for computing orphan pages, link depth, and missing connections programmatically.

To build the node list, the sitemap serves as the fastest source. Parse the sitemap to obtain the full set of URLs, then crawl the HTML to extract the edges. The XMLParser module helps in parsing the sitemap XML, and the fetch function is used to retrieve the URLs from the sitemap. If the sitemap contains other sitemaps, they are recursively parsed.

The edge list is built from the HTML of each URL. Cheerio library is used to parse the HTML and extract all internal anchor tags. The URLs are then normalized and added to a set to avoid duplicates. The extracted links are stored in an adjacency table, where each URL is a key and its corresponding value is an array of URLs it links to.

Depth of a page, often used as a proxy for authority, can be computed using a breadth-first search algorithm. The computeDepth function takes the adjacency table and a root URL as input. It initializes a depth map with the root page at depth 0 and a queue with the root page. The algorithm iteratively dequeues a page, checks its adjacent pages, and enqueues them if they haven't been visited yet. The depth of each page is stored in the depth map.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Why your pages are crawled but not indexed

Why your pages are crawled but not indexed "Crawled, currently not indexed" in Search Console gets treated as one problem with one fix, usually "publish better content." The status covers several…

  • Googlebot fetched URL but decided not to index
  • Canonical tag or JavaScript-rendered content may cause issue
  • URL Inspection API provides precise index status data

How to track Google Hotels prices with Python (no browser, no API key)

I built this actor; it's a paid tool on Apify with a free trial credit. Google Hotels shows you a price for every hotel in a city, but there's no official API for it.

  • Python script fetches hotel prices from Google Hotels without browser or API key.
  • Developed scraper called Google Hotels Scraper to overcome lack of official API.
  • Demonstrates calling scraper from Python and Node, data returned, and logging to Google Sheet.

Architectural Breakdown: I Pulled Nine Years of My Own Dev.to Data. The Numbers Were Not What I Expe

![ Architecture Diagram ]( https://image.pollinations.ai/prompt/high+performance+cloud+systems+I+Pulled+Nine+Years+of+My+Own++round+2?width=800&height=400&nologo=true ) # I Pulled Nine Years of My Own…

  • Author scraped nine years of Dev.to data using Python's standard library
  • 847 articles claimed by dashboard, but database only contained 612 records
  • 23% of supposed published content mysteriously disappeared between 2019-2023

More from Friday 25 September →