2 hours ago · Tech · hide · 0 comments

Much like a lot of other people, I subscribe to quite a few of the newsletters of TLDR. As I re-use the things I found there in own publications, I did find the newsletters – ironically – not quite succinct enough to go through them quickly. I wanted to skip sponsored sections and other cruft, so, of course I wrote a PHP script to help me with that. Here it is and you can find it on GitHub. $URLS = file_get_contents(‘tldrs.txt’); $out = ‘’; foreach (array_filter(explode(“n”, $URLS)) as $url) { echo $url . “n”; $html = file_get_contents($url); $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html); libxml_clear_errors(); $xpath = new DOMXPath($dom); $links = $xpath->query(‘//a’); foreach($links as $link) { $content = $link->nodeValue; if (strstr($content,’minute read’) || strstr($content,’GitHub Repo’)) { $text = trim( preg_replace( “/ (d+ minute read)|(GitHub Repo)/”, “”,$link->nodeValue) ); $details =…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.