Created
April 13, 2016 05:49
-
-
Save JacobHsu/63a81886af472b3a1a8c9925d204ddba to your computer and use it in GitHub Desktop.
#app #store #php
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 | |
$url = 'https://www.microsoft.com/zh-tw/store/apps/facebook/9wzdncrfhv5g'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_HEADER, false); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
$html = curl_exec($ch); | |
curl_close($ch); | |
$data = array(); | |
$data['name'] = strip_tags(_tag_content($html, '<h1 id="page-title" class="header-small m-v-n srv_title srv_microdata" itemprop="name">', "</h1>")); | |
$data['icon'] = _tag_content($html, '<div class="pull-left ph-logo m-r-md">', "</div>"); | |
preg_match('/<img(.*)src(.*)=(.*)"(.*)"/U', $data['icon'], $result); | |
$data['icon'] = array_pop($result); | |
$html_metadata = _tag_content($html, '<dl class="metadata-list row">', "</dl>"); | |
$html_metadata = explode('</dd>',$html_metadata); | |
$data['publisher'] = strip_tags(_tag_content($html_metadata[0], '<div class="content m-b-n clamp-5" data-vp1-lines="5" data-vp2-lines="5">', '</div>')); | |
$data['tag'] =strip_tags(_tag_content($html_metadata[1], '<div class="content m-b-n clamp-5" data-vp1-lines="5" data-vp2-lines="5">', '</div>')); | |
$data['description'] = _tag_content($html, '<p class="content m-b-n has-newline" data-vp1-lines="4" data-vp2-lines="3">', "</p>"); | |
print_r($data); exit; | |
function _tag_content($html, $start, $end) | |
{ | |
$html = str_replace($start, "", strstr($html, $start)); | |
return strstr($html, $end, true); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment