Last active
December 3, 2020 15:12
-
-
Save VerifiedJoseph/b756487fa5d5fd1da78030818d2f273a to your computer and use it in GitHub Desktop.
PHP script for extracting google poly user and item links from a Link Gopher output file
This file contains 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
<?php | |
/* | |
PHP script for extracting google poly user and item links from a Link Gopher output file and save them to csv files. | |
Dependencies: | |
PHP Simple HTML DOM Parser https://simplehtmldom.sourceforge.io/ | |
*/ | |
require __DIR__ . '/simple_html_dom.php'; | |
$temsFile = 'items.csv'; | |
$usersFile = 'users.csv'; | |
$htmlFile = 'Link Gopher.html'; | |
$html = file_get_contents($htmlFile); | |
$html = str_get_html($html); | |
$temsOutput = fopen($temsFile, 'w'); | |
$usersOutput = fopen($usersFile, 'w'); | |
foreach ($html->find('a') as $a) { | |
if (preg_match('/https:\/\/poly.google.com\/view\//', $a->href, $match)) { | |
fputcsv($temsOutput, array($a->href), ','); | |
} | |
if (preg_match('/https:\/\/poly.google.com\/user\//', $a->href, $match)) { | |
fputcsv($usersOutput, array($a->href), ','); | |
} | |
} | |
fclose($temsOutput); | |
fclose($usersOutput); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment