今天打算把 fontawesome 图标聚集起来,作为图标库选择,于是采用了php才抓取采集!
开始使用,
composer require jaeger/querylist
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
require_once 'vendor/autoload.php'; $html = file_get_contents('http://fontawesome.io/icons/'); $data = \QL\QueryList::Query($html,array( 'text' => array('.fontawesome-icon-list i','class') ))->getData(function($item){ $item['text'] = substr($item['text'],3,20); return $item; }); $faData = []; for ($i = 0; $i < count($data); $i++) { $faData[] = $data[$i]['text']; } file_put_contents('./Config/fontawesome.json',json_encode($faData)); print_r($faData); |
然以已经全部采集好了,结果如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
( ...... [963] => fa-ambulance [964] => fa-h-square [965] => fa-heart [966] => fa-heart-o [967] => fa-heartbeat [968] => fa-hospital-o [969] => fa-medkit [970] => fa-plus-square [971] => fa-stethoscope [972] => fa-user-md [973] => fa-wheelchair [974] => fa-wheelchair-alt ) |