Changeset 1113226
- Timestamp:
- 03/15/2015 04:29:21 PM (10 years ago)
- Location:
- plugins/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/trunk/plugins.php
r888150 r1113226 5 5 Plugin URI: http://marto.lazarov.org/plugins/plugins 6 6 Description: List wordpress contributor plugins and their stats 7 Version: 2.1.47 Version: 3.0.0 8 8 Author: mlazarov 9 9 Author URI: http://marto.lazarov.org/ … … 83 83 } 84 84 if($settings['updated'] > (time()-600)) continue; 85 85 86 $url = 'http://profiles.wordpress.org/'.$settings['author'].'/'; 86 87 $html = file_get_contents($url); 87 88 preg_match_all('#<h3>\s+<a href="//wordpress.org/plugins/([^/]+)/">([^<]+)</a>\s+</h3>\s+<p class="downloads">([0-9,]+) downloads</p>#ismU',$html,$matches,PREG_SET_ORDER); 88 89 if(class_exists('DOMDocument') && class_exists('DOMXPath')){ 90 $this->parseUsingDom($html,$id); 91 }else{ 92 $this->parseUsingPreg($html,$id); 93 } 89 94 90 $this->settings[$id]['plugins'] = array();91 foreach($matches as $k=>$m){92 $this->settings[$id]['plugins'][$m[1]]['name'] = $m[2];93 $this->settings[$id]['plugins'][$m[1]]['downloads'] = $m[3];94 }95 95 uasort($this->settings[$id]['plugins'],'dlsort'); 96 96 $this->settings[$id]['updated'] = time(); 97 97 } 98 98 $this->save_settings($this->settings); 99 } 100 function parseUsingPreg($html,$id){ 101 preg_match_all('#<h3>\s+<a href="//wordpress.org/plugins/([^/]+)/">([^<]+)</a>\s+</h3>\s+<p class="downloads">([0-9,]+) downloads</p>#ismU', 102 $html,$matches,PREG_SET_ORDER); 103 104 $this->settings[$id]['plugins'] = array(); 105 foreach($matches as $k=>$m){ 106 $this->settings[$id]['plugins'][$m[1]]['name'] = $m[2]; 107 $this->settings[$id]['plugins'][$m[1]]['downloads'] = $m[3]; 108 } 109 110 111 } 112 function parseUsingDom($html,$id){ 113 $dom = new DOMDocument; 114 $dom->loadHTML($html); 115 $xpath = new DOMXPath($dom); 116 117 $nlist = $xpath->query("//div[@class='plugin-info-container']"); 118 foreach($nlist as $im=>$div){ 119 if($div->hasChildNodes()){ 120 $nodes = $div->childNodes; 121 //$html = $div->c14n(); 122 123 $href = $nodes->item(1)->childNodes->item(1)->getAttribute('href'); 124 preg_match('#wordpress.org/plugins/([^/]+)#',$href,$m); 125 $slug = $m[1]; 126 $name = trim($nodes->item(1)->textContent); 127 $dls = trim($nodes->item(3)->textContent); 128 129 $this->settings[$id]['plugins'][$slug]['name'] = $name; 130 $this->settings[$id]['plugins'][$slug]['downloads'] = $dls; 131 132 } 133 } 99 134 } 100 135 } -
plugins/trunk/readme.txt
r888149 r1113226 26 26 27 27 == Changelog == 28 = 3.0.0 = 29 * Adding new html parser method (using dom if available) 28 30 29 31 = 2.1.4 = 30 * Fixin wordpress user profile url and html parsing32 * Fixing wordpress user profile url and html parsing 31 33 32 34 = 2.1.2 =
Note: See TracChangeset
for help on using the changeset viewer.