Skip to content

Instantly share code, notes, and snippets.

@mavitm
Last active May 23, 2017 21:28
Show Gist options
  • Save mavitm/3cba9295f78ac34e2ff4146fb1bf0929 to your computer and use it in GitHub Desktop.
Save mavitm/3cba9295f78ac34e2ff4146fb1bf0929 to your computer and use it in GitHub Desktop.
page info
<?php
use Goutte\Client;
use GuzzleHttp\Client as GuzzleClient;
use Illuminate\Filesystem\Filesystem;
$mavitm = \MtmCore\Mavitm::getInstance();
$Admin = new \MtmCore\Admin();
function createAyerFile($finfo){
$client = new Client();
$storage = new Filesystem();
$guzzleClient = new GuzzleClient([
'curl' => [
CURLOPT_TIMEOUT => 120
],
]);
$client->setClient($guzzleClient);
$crawler = $client->request("get","http://g....e.com/".$finfo['fileName']);
$title = $crawler->filter("title")->text();
$description = $crawler->filterXpath("//meta[@name='Description']")->attr('content');
$description || $description = $crawler->filterXpath("//meta[@name='description']")->attr('content');
$dataFile = str_replace('.php','.ayer', $finfo['file']);
$finfo['title'] = $title;
$finfo['pageName'] = $title;
$finfo['pageDescription'] = $description;
$variable = \MtmCore\Mavitm::getInstance()->Tools->jsonEncode($finfo);
return $storage->put($dataFile, $variable);
}
foreach($Admin->sayfaList as $f){
if(empty($f['pageName'])){
$b = createAyerFile($f);
echo '<pre>';
print_r($f);
echo '</pre>';
#refresh 2sn
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment