Giter Site home page Giter Site logo

phpquery-single's Introduction

phpQuery-single

phpQuery onefile composer.Continuous maintenance,Welcome PR.

QueryList base on phpQuery: https://github.com/jae-jae/QueryList

phpQuery单文件版本,持续维护,欢迎PR.

phpQuery项目主页:http://code.google.com/p/phpquery/

QueryList是基于phpQuery的采集工具: https://github.com/jae-jae/QueryList

Composer Installation

Packagist: https://packagist.org/packages/jaeger/phpquery-single

composer require jaeger/phpquery-single

Usage

$html = <<<STR
<div id="one">
    <div class="two">
        <a href="http://querylist.cc">QueryList官网</a>
        <img src="http://querylist.cc/1.jpg" alt="这是图片">
        <img src="http://querylist.cc/2.jpg" alt="这是图片2">
    </div>
    <span>其它的<b>一些</b>文本</span>
</div>        
STR;

$doc = phpQuery::newDocumentHTML($html);

$src = $doc->find('.two img:eq(0)')->attr('src');

echo $src;
// http://querylist.cc/1.jpg

phpquery-single's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpquery-single's Issues

QueryList v3版 有时候采集不全

`
$webUrl = 'https://www.mm131.net/';
require 'inc/phpQuery.php';
require 'inc/QueryList.php';
use QL\QueryList;

//拼装列表页(内含菜单名、菜单ID、页码):https://www.mm131.net/xinggan/list_6_7.html
function listUrl($catName,$catId,$page=1){
global $webUrl;
$url = $webUrl.$catName.'/';
if($page > 1){
$url = $url . 'list_'.$catId.'_'.$page.'.html';
}
return $url;
}

function getArtUrl($url){

$rules = ['link' => ['a:eq(0)','href']];
$range = '.list-left dd:not(:last)';
$data = QueryList::Query($url,$rules,$range)->data;

echo '采集到本页数据量为:'.count($data);

}
`
列表页一页有20条数据,有时候只能采集到12-14条,有时候有是20条,全看运气,也不见报错

PHP 8.1 compatibility

Hi,

I just figured out that if running under PHP 8.1 your code isn't runnable yet:

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /vendor/jaeger/phpquery-single/phpQuery.php on line 192

On line 192 you are passing $contentType (which is null by default) - so there need to be a check, wether it is null or not.

$this->contentType = strtolower($contentType);

The fix could be like this:

$this->contentType = strtolower(isset($contentType) ? $contentType : "");

Could you update your code at this part? I have seen that it gets auto-updated at packagist :-)

Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.