Skip to content

Commit

Permalink
🐛 fix scrap
Browse files Browse the repository at this point in the history
  • Loading branch information
matyo91 committed Sep 10, 2024
1 parent daf78e8 commit 34297cc
Showing 1 changed file with 78 additions and 4 deletions.
82 changes: 78 additions & 4 deletions src/Command/ScrapCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Component\String\Slugger\SluggerInterface;

use function count;
use function sprintf;
Expand All @@ -31,11 +34,18 @@
class ScrapCommand extends Command
{
private HttpClientInterface $httpClient;

public function __construct(HttpClientInterface $httpClient)
{
private string $cacheDir;
private SluggerInterface $slugger;

public function __construct(
HttpClientInterface $httpClient,
ParameterBagInterface $parameterBag,
SluggerInterface $slugger
) {
parent::__construct();
$this->httpClient = $httpClient;
$this->cacheDir = $parameterBag->get('kernel.cache_dir');
$this->slugger = $slugger;
}

/**
Expand Down Expand Up @@ -82,7 +92,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return $urlDatas;
};
yield [new ScrapUrlJob(), null, new FlattenIpStrategy()];

Check failure on line 94 in src/Command/ScrapCommand.php

View workflow job for this annotation

GitHub Actions / Execute PHPStan analysis (8.3)

Instantiated class Flow\IpStrategy\FlattenIpStrategy not found.
yield static function (UrlContent $urlData) use ($io) {
yield function (UrlContent $urlData) use ($io) {
$filesystem = new Filesystem();
$scrapDir = $this->cacheDir . '/scrap';

$filesystem->mkdir($scrapDir);

$slug = $this->slugger->slug($urlData->title)->lower();

$filename = $scrapDir . '/' . $slug . '.html';

$filesystem->dumpFile($filename, $urlData->content);

$io->writeln(sprintf('Content saved to: %s', $filename));
$io->writeln(sprintf('ScrapUrlJob : Finished scrapping %s', $urlData->url));
};

Expand Down Expand Up @@ -142,6 +164,58 @@ protected function execute(InputInterface $input, OutputInterface $output): int
};
}, ['driver' => $driver]);

$urls = [
['https://github.com/Jmgr/actiona','Actiona Cross platform automation tool'],
['https://github.com/tryanything-ai/anything','Anything Local Zapier replacement written in Rust'],
['https://airflow.apache.org','Apache Airflow'],
['http://apify.com','Apify'],
['https://itnext.io/smart-developers-dont-code-2bf882568c37','Apache Camel'],
['https://play.google.com/store/apps/details?id=com.llamalab.automate','Automate'],
['https://www.automa.site','Automa Automate your browser by connecting blocks'],
['https://www.blitznocode.com','Blitznocode'],
['https://fr.bonitasoft.com','Bonitasoft'],
['https://camunda.com','Camunda'],
['https://github.com/bolinfest/chickenfoot','Chickenfoot'],
['https://github.com/DataFire/DataFire','Datafire'],
['https://github.com/antonmi/flowex','Flowex'],
['http://www.flogo.io','Flogo'],
['https://www.flyde.dev','Flyde Visual Programming on VS Code'],
['https://developers.google.com/blockly','Google Blockly'],
['https://gluedata.io','Gluedata'],
['https://github.com/huginn/huginn','Huginn'],
['https://ifttt.com','IFTTT'],
['https://www.integromat.com','Integromat'],
['https://github.com/integrate-io','Integrate-io'],
['https://github.com/kestra-io/kestra','Kestra'],
['https://www.levity.ai','Levity'],
['https://github.com/n8n-io/n8n','n8n.io'],
['https://noflojs.org','NoFlo'],
['https://nodered.org','Nodered'],
['https://parabola.io','Parabola'],
['https://www.prefect.io','Prefect'],
['https://pipedream.com','Pipedream'],
['https://www.refinery.io','Refinery.io'],
['https://scratch.mit.edu','Scratch'],
['https://apps.apple.com/us/app/scriptable/id1405459188','Scriptable.app'],
['https://apps.apple.com/us/app/shortcuts/id915249334','Shortcut for iOS'],
['https://github.com/pfgithub/scpl','Shocut like for Mac OS'],
['https://github.com/steventroughtonsmith/shortcuts-iosmac','Shortcut like'],
['https://skyvia.com','Skyvia'],
['https://github.com/temporalio/samples-php','Temporal'],
['https://titanoboa.io','Titanoboa'],
['https://tray.io','Tray.io'],
['https://ui.vision/x/desktop-automation','UIVision'],
['https://www.workato.com','Workato'],
['https://zapier.com','Zapier'],
];

$datas = array_map(function($data) {
[$url, $title] = $data;
return new UrlContent($url, $title);
}, $urls);

$flow(new Ip($datas));

$flow(new Ip([
new UrlContent('https://www.google.fr'),
new UrlContent('https://www.apple.com'),
Expand Down

0 comments on commit 34297cc

Please sign in to comment.