PHPackages                             cloudsthere/phpcrawler - 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. cloudsthere/phpcrawler

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

cloudsthere/phpcrawler
======================

1.21(10y ago)026MITPHP

Since Jun 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/cloudsthere/phpcrawler)[ Packagist](https://packagist.org/packages/cloudsthere/phpcrawler)[ RSS](/packages/cloudsthere-phpcrawler/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

### PHP网页爬虫

[](#php网页爬虫)

##### 实现目标：抓取后即可正常显示网页

[](#实现目标抓取后即可正常显示网页)

##### 安装： `$ composer require cloudsthere/phpcrawler`

[](#安装--composer-require-cloudstherephpcrawler)

##### 使用方法：

[](#使用方法)

```
$base_url = 'http://target/url';

$cookies = true; // 默认
// $cookies = 'key=abc; key1=123';
// $cookies = [
//     'key' => 'abc',
//     'key1' => '123',
// ];

$config = [
    // 保存文件目录
    'dir' => '/Applications/MAMP/htdocs/web/',
    'log_level' => 2,
    // 若值为false, 表示不使用cookie
    // 若值为true, 表示使用cookie，并且cookie会随服务器操作而改变
    // 若指定cookie值(数组或字符串), 则cookie始终为设定值，不受服务器影响
    'cookies' => $cookies,
    // http请求头，一般不需要设置
    'headers' => [
        'foo' => 'bar',
        'User-Agent' => $_SERVER['HTTP_USER_AGENT'],
    ],
    // 注意：参数method, form_params和multipart，只对种子页生效，其派生的页面都将使用默认设置。
    // 默认方法为get。
    'method' => 'post',
    // 使用 x-www-form-urlencoded 编码
    'form_params' => [
        'hello' => 'beauty',
    ],
    // 注意 multipart与form_params不能同时使用
    // 使用 multipart/form-data 编码
    // 'multipart' => [
    //     [
    //         'name'     => 'field_name',
    //         'contents' => 'abc'
    //     ],
    //     [
    //         'name'     => 'file_name',
    //         'contents' => fopen('LICENSE', 'r')
    //     ],
    //     [
    //         'name'     => 'other_file',
    //         'contents' => 'hello',
    //         'filename' => 'filename.txt',
    //     ]
    // ],
];

$crawler = new phpcrawler\Crawler($base_url, $config);

// 循环解析网页的次数，如果为1(数字)，表示只解析种子页面的url。如果为true(默认), 表示无限循环，直到没有发现新的url。
$loop = 1;
$crawler->crawl($loop);

```

##### 建议：

[](#建议)

```
强烈建议使用cookie代替表单提交。当抓取需要session验证的页面时（比如登录），一般会模拟表单提交，这时就会处理表单字段可能很麻烦。其实使用cookie会更省时省力。
个人推荐方法：在浏览器正常登录后，查看页面的http头，直接复制cookie字符串到本项目config中的cookie元素即可。这时用程序访问该站内任何页面（除logout），都会认为请求处于登录状态。

```

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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

Every ~2 days

Total

6

Last Release

3690d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/cloudsthere-phpcrawler/health.svg)

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

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k832.6k52](/packages/neuron-core-neuron-ai)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

762297.9k52](/packages/civicrm-civicrm-core)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M49](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

39255.4k37](/packages/ec-europa-toolkit)[oat-sa/tao-core

TAO core extension

64147.9k151](/packages/oat-sa-tao-core)

PHPackages © 2026

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