seotracker/seocore

php的seo-core库

1.0.3 2017-11-03 16:33 UTC

This package is auto-updated.

Last update: 2024-09-05 18:02:00 UTC


README

Seo-core库是从Seo-Tracker平台提取的。这是处理网站、搜索引擎和爬虫的常用方法。

Build Status SensioLabsInsight

网站

网站是真实网站的物体表示。网站必须有HTML内容。

网站对象可以返回SEO有用的数据,例如

  • 网站标题
  • 网站元数据及丰富内容
  • 网站关键词出现次数和比例(未实现)
  • 网站定位URL

有关更多信息,请参阅WebsiteInterface

搜索引擎

搜索引擎是真实搜索引擎的物体表示。搜索引擎应使用爬虫从互联网网络获取信息。

搜索引擎可以返回SEO有用的数据,例如

  • 针对某个关键词的所有网站
  • 针对某个关键词在相关搜索引擎中的网站排名
  • 在此搜索引擎中网站的所有反向链接

有关更多信息,请参阅SearchEngineInterface

爬虫

爬虫是用于从互联网网络获取HTML的对象。

由于此对象只有一个任务,唯一的实现方法是get,它接受至少一个参数:URL位置。

请参阅ScrapperInterface和在Adapter\Scrapper文件夹中的实现。

爬虫

爬虫是用于查询和操作HTML DOM的对象。

Seo-core提供接口及其基于Symfony2-Component的实现。

请参阅CrawlerInterface和在Adapter\Crawler文件夹中的实现。

示例

<?php
use SeoTracker\SeoCore\Adapter\Crawler\SymfonyCrawler;
use SeoTracker\SeoCore\Adapter\Scrapper\CurlScrapper;
use SeoTracker\SeoCore\Model\GoogleFranceEngine;

$crawler   = new SymfonyCrawler();
$scrapper = new CurlScrapper();
$googleEngine = new GoogleFranceEngine($scrapper, $crawler);

$website = $googleEngine->getWebsite('http://seo-tracker.net');

// position of website in Google
$position = $googleEngine->getPosition('seo tools online platform', $website); // 1

// title of website
$title = $website->getTitle(); // 'SeoTracker : A SEO tools suite'

// metas of website
$metas = $googleEngine->getMetas();
// ['description' => 'Seo Tracker est une plateforme de suivi et d'optimisation [..]']

// microdatas of website
$microDatas = $googleEngine->getMicroDatas();
/**
 * [0 =>
 *     'type' =>
 *         [0 => 'http://www.schema.org/CreativeWork']
 *     ,
 *     'properties' => [...]]
 * ],
 * [ 1 => [..] ]
 **/

// backlinks of website location in search engine
$backlinks = $googleEngine->getBacklinks($website);
/**
 * [
 *     0 => 'http://seo-core.com',
 *     1 => 'http://otherwebsite.backlink'
 * ]
 **/