public function getBulkData($limit = 1, $sentences = 5, $chars = 200, $with_images = false, $image_min_size = 102400)
    {
        $wiki_api = $this->base_api . 'action=query&generator=random&grnnamespace=0&grnlimit=' . $limit . '&prop=info|extracts&inprop=url&explaintext=&exsectionformat=plain';

        if ($sentences > 0) {
            $wiki_api .= '&exsentences=' . $sentences;
        } elseif ($chars) {
            $wiki_api .= '&exchars=' . $chars;
        }

        $json_wapi = json_decode(file_get_contents($wiki_api), true);
        $result = [];

        if (!$json_wapi) {
            return $result;
        }

        foreach ($json_wapi['query']['pages'] as $page_id => $item) {
            $result[$page_id] = [
                'page_id' => $page_id,
                'title'   => $item['title'],
                'length'  => $item['length'],
                'url'     => $item['fullurl'],
                'text'    => isset($item['extract']) ? $item['extract'] : '',
            ];
        }

        $this->article_ids = array_keys($result);
        if ($with_images) {
            foreach ($this->article_ids as $page_id) {
                $wiki_api = $this->base_api . 'action=query&generator=images&prop=imageinfo&iiprop=url|size&pageids=' . $page_id;
                $json_wapi = json_decode(file_get_contents($wiki_api), true);
                $images = array();
                if ($json_wapi) {
                    foreach ($json_wapi['query']['pages'] as $item) {
                        $imageinfo = $item['imageinfo'][0];
                        if ($image_min_size > 0 && $imageinfo['size'] < $image_min_size) {
                            continue;
                        }
                        $images[] = $imageinfo['url'];
                    }
                }
                $result[$page_id]['images'] = $images;
            }
        }

        return array_values($result);
    }
public function getBulkData($limit = 1, $sentences = 5, $chars = 200, $with_images = false, $image_min_size = 102400)
    {
        $wiki_api = $this->base_api . 'action=query&generator=random&grnnamespace=0&grnlimit=' . $limit . '&prop=info|extracts&inprop=url&explaintext=&exsectionformat=plain';

        if ($sentences > 0) {
            $wiki_api .= '&exsentences=' . $sentences;
        } elseif ($chars) {
            $wiki_api .= '&exchars=' . $chars;
        }

        $json_wapi = json_decode(file_get_contents($wiki_api), true);
        $result = [];

        if (!$json_wapi) {
            return $result;
        }

        foreach ($json_wapi['query']['pages'] as $page_id => $item) {
            $result[$page_id] = [
                'page_id' => $page_id,
                'title'   => $item['title'],
                'length'  => $item['length'],
                'url'     => $item['fullurl'],
                'text'    => isset($item['extract']) ? $item['extract'] : '',
            ];
        }

        $this->article_ids = array_keys($result);
        if ($with_images) {
            foreach ($this->article_ids as $page_id) {
                $wiki_api = $this->base_api . 'action=query&generator=images&prop=imageinfo&iiprop=url|size&pageids=' . $page_id;
                $json_wapi = json_decode(file_get_contents($wiki_api), true);
                $images = array();
                if ($json_wapi) {
                    foreach ($json_wapi['query']['pages'] as $item) {
                        $imageinfo = $item['imageinfo'][0];
                        if ($image_min_size > 0 && $imageinfo['size'] < $image_min_size) {
                            continue;
                        }
                        $images[] = $imageinfo['url'];
                    }
                }
                $result[$page_id]['images'] = $images;
            }
        }

        return array_values($result);
    }
public function getBulkData ( $ limit = 1 , $ sentences = 5 , $ chars = 200 , $ with_images = false , $ image_min_size = 102400 ) { $ wiki_api = $ this -> base_api . 'action=query&generator=random&grnnamespace=0&grnlimit=' . $ limit . '&prop=info|extracts&inprop=url&explaintext=&exsectionformat=plain' ; if ( $ sentences > 0 ) { $ wiki_api .= '&exsentences=' . $ sentences ; } elseif ( $ chars ) { $ wiki_api .= '&exchars=' . $ chars ; } $ json_wapi = json_decode ( file_get_contents ( $ wiki_api ) , true ) ; $ result = [ ] ; if ( ! $ json_wapi ) { return $ result ; } foreach ( $ json_wapi [ 'query' ] [ 'pages' ] as $ page_id => $ item ) { $ result [ $ page_id ] = [ 'page_id' => $ page_id , 'title' => $ item [ 'title' ] , 'length' => $ item [ 'length' ] , 'url' => $ item [ 'fullurl' ] , 'text' => isset ( $ item [ 'extract' ] ) ? $ item [ 'extract' ] : '' , ] ; } $ this -> article_ids = array_keys ( $ result ) ; if ( $ with_images ) { foreach ( $ this -> article_ids as $ page_id ) { $ wiki_api = $ this -> base_api . 'action=query&generator=images&prop=imageinfo&iiprop=url|size&pageids=' . $ page_id ; $ json_wapi = json_decode ( file_get_contents ( $ wiki_api ) , true ) ; $ images = array ( ) ; if ( $ json_wapi ) { foreach ( $ json_wapi [ 'query' ] [ 'pages' ] as $ item ) { $ imageinfo = $ item [ 'imageinfo' ] [ 0 ] ; if ( $ image_min_size > 0 && $ imageinfo [ 'size' ] < $ image_min_size ) { continue ; } $ images [ ] = $ imageinfo [ 'url' ] ; } } $ result [ $ page_id ] [ 'images' ] = $ images ; } } return array_values ( $ result ) ; }
Get Bulk Data
@param  integer $limit
@param  integer $sentences
@param  integer $chars
@param  boolean $with_images
@param  integer $image_min_size
@return array
Get Bulk Data