Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jeankassio committed Apr 29, 2023
2 parents b4ff30d + 4f99c3a commit 2933f92
Showing 1 changed file with 126 additions and 2 deletions.
128 changes: 126 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,126 @@
# Sioner-Metadata-Extractor
Sioner Metadata Extractor uses Chromedriver to extract metadata from websites with javascript, even if it is written in PHP
# Sioner Metadata Extractor
Sioner Metadata Extractor uses Chromedriver to extract metadata from websites with javascript using Symfony/Panther.

[![Total Downloads](https://poser.pugx.org/jeankassio/Sioner-Metadata-Extractor/downloads)](https://packagist.org/packages/jeankassio/sioner-metadata-extractor)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

### Installing Sioner

Use [Composer](https://getcomposer.org/) to install Sioner in your project:

```sh
composer require jeankassio/sioner-metadata-extractor
````

### Installing ChromeDriver

Sioner uses the WebDriver protocol used by Panther to crawl sites.

On all systems, you can use [`dbrekelmans/browser-driver-installer`](https://github.com/dbrekelmans/browser-driver-installer)
to install ChromeDriver locally:

composer require --dev dbrekelmans/bdi
vendor/bin/bdi detect drivers


# Usage

### Here is some available metadata that was returned by Sioner Metadata Extractor:


```json
{
"domain":"github.com",
"canonical":"https:\/\/github.com\/jeankassio\/Sioner-Metadata-Extractor",
"title":"GitHub - jeankassio\/Sioner-Metadata-Extractor: Sioner Metadata Extractor uses Chromedriver to extract metadata from websites with javascript, even if it is written in PHP",
"image":"https:\/\/opengraph.githubassets.com\/b22dbba9d6ae7f1bf3f540334ce5b7c01e728daa06739db48430ca0804af9ab0\/jeankassio\/Sioner-Metadata-Extractor",
"description":"Sioner Metadata Extractor uses Chromedriver to extract metadata from websites with javascript, even if it is written in PHP - GitHub - jeankassio\/Sioner-Metadata-Extractor: Sioner Metadata Extracto...",
"icon":"https:\/\/github.com\/favicon.ico"
}
```

```json
{
"domain":"techland.time.com",
"canonical":"https:\/\/techland.time.com\/2011\/04\/06\/linux-exec-competing-against-microsoft-is-like-kicking-a-puppy\/",
"title":"Linux Exec: Competing Against Microsoft Is Like “Kicking a Puppy” | TIME.com",
"image":"https:\/\/techland.time.com\/wp-content\/themes\/time2012\/library\/assets\/images\/time-logo-og.png",
"description":"Depending who you ask, you'll get a different answer about who's winning the operating system wars. Of course, the Linux people think they've won, but here's the thing--they may be right.",
"keywords":"business, news, linux, open-source, windows",
"icon":"https:\/\/techland.time.com\/favicon.ico"
}
```

```json
{
"domain": "domain string",
"canonical": "og:canonical link string",
"title": "og:title/title website string",
"image": "og:image/first image string",
"description": "og:description/description string",
"keywords": "keywords string",
"icon": "apple-touch-icon/icon string",
"author": "og:author/author string",
"copyright": "copyright string"
}
```

## How it works?

Sioner Metadata Extractor can, before running completely in the determined amount of seconds (explained later), quickly run the search for the determined data and obtain this data without the need to use javascript, thus saving its execution time.
To do this, just pass the data you want to obtain as mandatory in the first verification as parameter #4

```php
use JeanKassio\Sioner\MetadataExtractor
$YourLink = "https://github.com/jeankassio/Sioner-Metadata-Extractor";
$code = new MetadataExtractor($YourLink, null, null, ['website', 'title', 'image', 'description']);
$response = $code->ExtractMetadata();
echo json_encode($response, JSON_UNESCAPED_UNICODE);
```

But if that doesn't happen, it will run the Browser with javascript to get the data. The time for which it will run by default is 3 seconds, but you can change this value by setting parameter #2
```php
use JeanKassio\Sioner\MetadataExtractor
$YourLink = "https://github.com/jeankassio/Sioner-Metadata-Extractor";
$code = new MetadataExtractor($YourLink, 2.5); //2.5 seconds
$response = $code->ExtractMetadata();
echo json_encode($response, JSON_UNESCAPED_UNICODE);
```
We get og:image by default of 200x200, and if it's not found, the next image larger than that dimension will be returned. If none match, the largest is returned. But you can also set these values.

```php
use JeanKassio\Sioner\MetadataExtractor
$YourLink = "https://github.com/jeankassio/Sioner-Metadata-Extractor";
$code = new MetadataExtractor($YourLink, null, [250,300]); //250 width, 300 height
$response = $code->ExtractMetadata();
echo json_encode($response, JSON_UNESCAPED_UNICODE);
```

And that way you can pass the parameters you want and build the way you want. Watch

```php
use JeanKassio\Sioner\MetadataExtractor
$YourLink = "https://github.com/jeankassio/Sioner-Metadata-Extractor";
$code = new MetadataExtractor($YourLink, 5, [500,100], ['website', 'title', 'image', 'description']);
$response = $code->ExtractMetadata();
echo json_encode($response, JSON_UNESCAPED_UNICODE);
```

0 comments on commit 2933f92

Please sign in to comment.