2017 © Pedro Peláez
 

library php-dom-crawl

Fetch Html Dom Texts based on Php Script.

image

bjd/php-dom-crawl

Fetch Html Dom Texts based on Php Script.

  • Tuesday, August 9, 2016
  • by baijingdong
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

# PhpDomCrawl

Introduce

The core htmldomparse code source using https://sourceforge.net/p/simplehtmldom/code/HEAD/tree/trunk/simple_html_dom.php, (*1)

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

Install

checking packagist inorder to acquire the latest vesion. https://packagist.org/packages/bjd/php-dom-crawl, (*3)

add the following parameters:, (*4)

composer require bjd/php-dom-crawl, (*5)

How to Use

Acquire Content html text value just like use Javascript Dom parse, (*6)

an exmple of crawl test ShadowSocks Account. using under yiiframe work, (*7)


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); } }

The Versions

09/08 2016

dev-master

9999999-dev https://github.com/baijingdong/PhpDomCrawl

Fetch Html Dom Texts based on Php Script.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4.0

 

php html dom

09/08 2016

v1.0.3

1.0.3.0 https://github.com/baijingdong/PhpDomCrawl

Fetch Html Dom Texts based on Php Script.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4.0

 

php html dom

09/08 2016

v1.0.2

1.0.2.0 https://github.com/baijingdong/PhpDomCrawl

Fetch Html Dom Texts based on Php Script.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4.0

 

php html dom

09/08 2016

v1.0.1

1.0.1.0 https://github.com/baijingdong/PhpDomCrawl

Fetch Html Dom Texts based on Php Script.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4.0

 

php html dom

09/08 2016

v1.0.0

1.0.0.0 https://github.com/baijingdong/PhpDomCrawl

Fetch Html Dom Texts based on Php Script.

  Sources   Download

The Requires

  • php >=5.4.0

 

php html dom