定制 truercm/laravel-webscrape 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

truercm/laravel-webscrape

最新稳定版本:1.3.0

Composer 安装命令:

composer require truercm/laravel-webscrape

包简介

Scrape web paged within Laravel application

README 文档

README

Webscrape

Scrape web pages with a Laravel application.

Installation

You can install the package via composer:

composer require truercm/laravel-webscrape

You can publish and run the migrations with:

php artisan vendor:publish --tag="laravel-webscrape-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="laravel-webscrape-config"

This is the contents of the published config file:

return [

    /*
    |--------------------------------------------------------------------------
    | Webscrape models
    |--------------------------------------------------------------------------
    */
    'models' => [

        /*
        |--------------------------------------------------------------------------
        | Subject model holds the credentials, target_id and the final scraping result
        |--------------------------------------------------------------------------
        */
        'subject' => TrueRcm\LaravelWebscrape\Models\CrawlSubject::class,

        /*
        |--------------------------------------------------------------------------
        | Target model stores the remote target, authentication url and processing job
        |--------------------------------------------------------------------------
        */
        'target' => TrueRcm\LaravelWebscrape\Models\CrawlTarget::class,

        /*
        |--------------------------------------------------------------------------
        | TargetUrl model collects all URLs for the Target
        |--------------------------------------------------------------------------
        */
        'target_url' => TrueRcm\LaravelWebscrape\Models\CrawlTargetUrl::class,

        /*
        |--------------------------------------------------------------------------
        | Url Result model stores processed results
        |--------------------------------------------------------------------------
        */
        'result' => TrueRcm\LaravelWebscrape\Models\CrawlResult::class,
    ],

    /*
     |--------------------------------------------------------------------------
     | Selenium driver url
     |--------------------------------------------------------------------------
     */
    'selenium_driver_url' => env('SELENIUM_DRIVER_URL', null),
];

Laravel Webcrawler uses Selenium to crawl the pages, so make sure you have it installed.

Usage

This is a generic package, you would need to implement all the crawling steps yourself.

The high concept overview involves:

  1. Having a CrawlTarget - the model, containing the entry point to the list of pages you need to crawl
  2. Crawl subject - a model that connects the credentials with the crawl target

Once you have registered a target, you can:

  1. Initialize subject with credentials and target urls
  2. Start remote url crawling and processing the result
    $crawlSubject = \TrueRcm\LaravelWebscrape\Actions\StoreCrawlSubject::run([
        'model_type' => App\Models\User::class,
        'model_id' => 1,
        'crawl_target_id' => 1,
        'credentials' => ['values' => 'that would be piped', 'into' => 'crawl target'],
]);

and from here:

resolve($crawlSubject->crawlTarget->crawling_job)
    ->dispatch($crawlSubject);
  1. After the job is finished we have final result in CrawlSubject's result column
    $crawlSubject->result;

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固