PHPackages                             sobc/pquery - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sobc/pquery

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sobc/pquery
===========

类Jquery 节点选择器的类库

1.0.0(7y ago)3171MITPHPPHP &gt;=5.5

Since Jul 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/bianchengxiaosong/pQuery)[ Packagist](https://packagist.org/packages/sobc/pquery)[ RSS](/packages/sobc-pquery/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (2)Used By (0)

本项目是由PHP编写 支持PHP环境为5.5和5.5以上版本 主要使用jQuery的选择器语法，并支持多层级筛选 用于获取页面某一块的html内容或属性值 并支持页面中出现错误的、未闭合的html标签格式 比较适合抓取文章内容 url地址 图片地址等操作

安装方式 composer require sobc/pquery

引用并实例化方式 include\_once('./vendor/autoload.php'); $pquery = new \\sobc\\pquery\\Pquery($str);

目前支持筛选调用方法为 find(选择器语法)

目前支持的jQuery选择器语法为 基本选择器 #id element .class selector1,selctor2,selector3 属性 \[attribute\] \[attribute=value\]

获取内容方法为 $pquery = new sobc\\pquery\\Pquery($html); 获取多条内容 htmls() $htmls = $pquery-&gt;find('.class\_p')-&gt;find('a')-&gt;htmls(); $htmls = $pquery-&gt;find('.class\_p')-&gt;find('p')-&gt;htmls(function($key,$html){ //$key 代表索引 //$html 符合选择器的内容 return strtoupper($html); }); 获取第一条内容 html() 不支持传递任何参数 $html = $pquery-&gt;find('.class\_p\[name="attr\_value"\]')-&gt;html(); 获取含自身标签多条内容 fullhtmls() $fullhtmls = $pquery-&gt;find('.class\_fullhtmls\[name="attr\_value"\]')-&gt;fullhtmls(); $fullhtmls = $pquery-&gt;find('div,p')-&gt;fullhtmls(function($key,$fullhtml){ //$key 代表索引 //$fullhtml 符合选择器并含自身标签的内容 return strtoupper($fullhtml); }); 注意：返回结果会带有自身标签，如

内容

获取含自身标签第一条内容 fullhtml() 不支持传递任何参数 $fullhtml = $pquery-&gt;find('#id')-&gt;html() 获取属性方法为 获取多条对应属性 attrs() $attrs = $pquery-&gt;find('input\[name\]')-&gt;attrs(); $attrs = $pquery-&gt;find('input\[name\]')-&gt;attrs(function($key,$attr){ //$key 代表索引 //$attr 符合选择器的标签的属性 return $attr; }); 获取第一条对应 attr() $attr = $pquery-&gt;find('checkbox\[checked\]')-&gt;attr();支持jQuery的each方法 $pquery = new sobc\\pquery\\Pquery($html); $r = $pquery-&gt;find('a\[href\]')-&gt;each(function($key,$tag){ //$key 代表索引 //$tag 符合的标签节点 return $tag; })

开发者邮箱 开发者QQ 1847537660 如有问题 请加QQ联系并备注为pQuery 本人将尽快帮你解决 此项目还在开发中 后续会支持更多选择器

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2853d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce152add926ce55a88952c694bca14aadd87b28355fde724335d01cb4e9d432a?d=identicon)[bianchengxiaosong](/maintainers/bianchengxiaosong)

---

Top Contributors

[![bianchengxiaosong](https://avatars.githubusercontent.com/u/11548744?v=4)](https://github.com/bianchengxiaosong "bianchengxiaosong (4 commits)")

### Embed Badge

![Health badge](/badges/sobc-pquery/health.svg)

```
[![Health](https://phpackages.com/badges/sobc-pquery/health.svg)](https://phpackages.com/packages/sobc-pquery)
```

###  Alternatives

[freshbitsweb/laravel-cart-manager

Managing the cart of your Laravel application is a breeze

22622.3k1](/packages/freshbitsweb-laravel-cart-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
