承接 bjd/php-dom-crawl 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bjd/php-dom-crawl

Composer 安装命令:

composer require bjd/php-dom-crawl

包简介

Fetch Html Dom Texts based on Php Script.

README 文档

README

###Introduce The core htmldomparse code source using https://sourceforge.net/p/simplehtmldom/code/HEAD/tree/trunk/simple_html_dom.php

Now you can easily get this code through composer, It's requires PHP 5.4+ to run.

###Install

checking packagist inorder to acquire the latest vesion. https://packagist.org/packages/bjd/php-dom-crawl

add the following parameters:

composer require bjd/php-dom-crawl

###How to Use

Acquire Content html text value just like use Javascript Dom parse

an exmple of crawl test ShadowSocks Account. using under yiiframe work

namespace frontend\controllers;

use yii;
use yii\web\Controller;
use Bjd\PhpDom\PhpCrawl;




class TestController extends Controller{
    public function actionIndex(){
        $res_data =  $this->_getContent();
        $file_put_path = Yii::getAlias("@app/runtime/logs/ss.tmp");

        file_put_contents($file_put_path,$res_data);
        yii::$app->response->sendFile($file_put_path,"gui-config.json");
        yii::$app->end();

    }

    public function actionStr(){
        echo $this->_getContent();
    }

    private function _getContent(){
        $html = PhpCrawl::file_get_html("http://ss.yuvpn.com/page/testss.html");
        $res  = $html->find(".testvpnitem") ;


        $ss_vpn = [];
        foreach($res as $key=>$value){

            $text =  $value->innertext();
            $ss_vpn[$key]['server'] = $value->find("span")[0]->innertext();

            $matches = [];
            preg_match_all("'¶Ë¿Ú£º\s?(.*?)<br\s?/>'is",$text,$matches);
            $ss_vpn[$key]['server_port'] = $matches[1][0];
            preg_match_all("'ÃÜÂ룺\s?(.*?)<br\s?/>'is",$text,$matches);
            $ss_vpn[$key]['password'] = $matches[1][0];
            $ss_vpn[$key]['method'] = $value->find("span")[1]->innertext();
            $ss_vpn[$key]['remarks'] = $value->find("span")[0]->innertext();

        }


        $data = [
            "index" => count($ss_vpn),
            "global" => true,
            "enabled" => true,
            "shareOverLan" => false,
            "isDefault" => false,
            "localPort" => 1080
        ];
        $data['configs'] = $ss_vpn;
        return   json_encode($data);
    }

}

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: apache
  • 更新时间: 2016-08-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固