Skip to content

Instantly share code, notes, and snippets.

@fabiofidanza
Created December 20, 2021 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiofidanza/a134f7316ec1f4584001e1d299a31bda to your computer and use it in GitHub Desktop.
Save fabiofidanza/a134f7316ec1f4584001e1d299a31bda to your computer and use it in GitHub Desktop.
<?php
$page = file_get_contents('https://risorse.arcipelagoeducativo.it/risorse/crucipuzzle-dellorientamento');
$title_re = '/<title>([^\/]+)<\/title>/m';
preg_match_all($title_re, $page, $matches, PREG_SET_ORDER, 0);
$title = $matches[0][1];
$og_image_re = '/<meta.+property="og:image".+content="([^"]+)".+\/>/m';
preg_match_all($og_image_re, $page, $matches, PREG_SET_ORDER, 0);
$og_image = $matches[0][1];
$description_re = '/<meta.+name="description".+content="([^"]+)".+\/>/m';
preg_match_all($description_re, $page, $matches, PREG_SET_ORDER, 0);
$description = $matches[0][1];
print <<<YEAH
<img src="$og_image" />
<h1>$title</h1>
<p>
$description
</p>
YEAH;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment