negative/simplescraper

本包最新版本(dev-master)没有可用的许可证信息。

一个(非常)简单的URL抓取器,可以抓取标题、描述和图片。

dev-master 2014-05-02 16:54 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:00:22 UTC


README

Build Status

一个(非常)简单的URL抓取器,可以抓取标题、描述和图片。

安装

通过Composer安装

	composer require negative\simplescraper 

版本:dev-master。

添加

	'Negative\Simplescraper\SimplescraperServiceProvider'

到您的app/config.php $providers数组中

请检查vendor/negative/simplescraper/src/config/config.php以获取配置选项。

运行以下命令发布配置文件

php artisan config:publish negative/simplescraper

然后编辑以下目录下的配置文件

/app/config/packages/negative/simplescraper/config.php

就这样。

用法

只需调用

	Simplescraper::lookup('http://www.ikea.com/us/en/catalog/products/60202199/');

它将返回如下数组

	array(
		"url" => "http://www.ikea.com/us/en/catalog/products/60202199/",
		"title" => "FALSTER Table - gray  - IKEA",
		"description" => "IKEA - FALSTER, Table, gray , Polystyrene slats are weather-resistant and easy to care for.The furniture is both sturdy and lightweight as the frame is made of rustproof aluminum.You can easily sand down light scratches on the slates with fine sandpaper.",
		"images" => ["uploads/simplescraper/5329acc4378bb.jpg"]
	)

配置允许以下选项

// If defined, download the scraped images to this directory
// PLEASE NOTE: use a dedicated folder if you want to use download_ttl
'download_dir' => public_path().'/uploads/simplescraper/',

// Delete downloded images after (seconds)
// set to zero to prevent automatic cleanup
'download_ttl' => 120, 

// The maximum number of images to download
'max_imgs' => 1,

// Set a minimum size for the images that are shown.  This requires
// a download_dir to be set.
'minimum_size' => '300x200'

致谢

受Laraval 3 bundle Scrapey的启发 https://github.com/BKWLD/scrapey .