Update (front post): Fix parsing issue
This commit is contained in:
@@ -26,6 +26,7 @@ protected function schedule(Schedule $schedule): void
|
||||
AISerpGenArticleJob::dispatch()->onQueue('default')->onConnection('default');
|
||||
})->everyMinute()->when(function () use ($mins_between_posts, $launched_date) {
|
||||
$minutes_since_launch = now()->diffInMinutes($launched_date);
|
||||
|
||||
return $minutes_since_launch % $mins_between_posts === 0;
|
||||
});
|
||||
|
||||
|
||||
@@ -189,21 +189,26 @@ private function injectTableOfContents($html)
|
||||
}
|
||||
|
||||
// Create the Table of Contents
|
||||
$toc = '<div class="p-3 rounded-3 bg-light mb-3"><ol>';
|
||||
$h2Elements->each(function (Crawler $node, $i) use (&$toc) {
|
||||
$content = $node->text();
|
||||
$id = 'link-'.$i; // Creating a simple id based on the index
|
||||
$node->getNode(0)->setAttribute('id', $id); // Set the id to the h2 tag
|
||||
$toc .= "<li class=\"py-1\"><a class=\"text-decoration-none hover-text-decoration-underline\" href='#{$id}'>{$content}</a></li>";
|
||||
$domDocument = $crawler->getNode(0)->ownerDocument;
|
||||
$tocDiv = $domDocument->createElement('div');
|
||||
$tocDiv->setAttribute('class', 'p-3 rounded-3 bg-light mb-3');
|
||||
$ol = $domDocument->createElement('ol');
|
||||
$tocDiv->appendChild($ol);
|
||||
|
||||
$h2Elements->each(function (Crawler $node, $i) use ($ol) {
|
||||
$content = htmlspecialchars($node->text(), ENT_XML1 | ENT_COMPAT, 'UTF-8');
|
||||
$id = 'link-'.$i;
|
||||
$node->getNode(0)->setAttribute('id', $id);
|
||||
$li = $ol->appendChild(new \DOMElement('li'));
|
||||
$li->setAttribute('class', 'py-1');
|
||||
$a = $li->appendChild(new \DOMElement('a', $content));
|
||||
$a->setAttribute('class', 'text-decoration-none hover-text-decoration-underline');
|
||||
$a->setAttribute('href', '#'.$id);
|
||||
});
|
||||
$toc .= '</ol></div>';
|
||||
|
||||
// Insert TOC after h1
|
||||
$domDocument = $crawler->getNode(0)->ownerDocument;
|
||||
$fragment = $domDocument->createDocumentFragment();
|
||||
$fragment->appendXML($toc);
|
||||
$h1Node = $crawler->filter('h1')->getNode(0);
|
||||
$h1Node->parentNode->insertBefore($fragment, $h1Node->nextSibling);
|
||||
$h1Node->parentNode->insertBefore($tocDiv, $h1Node->nextSibling);
|
||||
|
||||
// Get the updated HTML
|
||||
$updatedHtml = $crawler->filter('body')->html();
|
||||
|
||||
@@ -4,22 +4,20 @@
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
|
||||
use LaravelGoogleIndexing;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
public function indexing(Request $request)
|
||||
{
|
||||
$url = $request->input('url');
|
||||
|
||||
if (is_null($url))
|
||||
public function indexing(Request $request)
|
||||
{
|
||||
abort(404);
|
||||
}
|
||||
$url = $request->input('url');
|
||||
|
||||
IndexNow::submit($url);
|
||||
LaravelGoogleIndexing::create()->update($url);
|
||||
}
|
||||
if (is_null($url)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
IndexNow::submit($url);
|
||||
LaravelGoogleIndexing::create()->update($url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,10 @@ public static function handle($post)
|
||||
{
|
||||
$keyword = $post->main_keyword;
|
||||
|
||||
if (is_array($post->keywords))
|
||||
{
|
||||
if (count($post->keywords) > 0)
|
||||
{
|
||||
$keyword .= " " . implode(" ", $post->keywords);
|
||||
}
|
||||
if (is_array($post->keywords)) {
|
||||
if (count($post->keywords) > 0) {
|
||||
$keyword .= ' '.implode(' ', $post->keywords);
|
||||
}
|
||||
}
|
||||
|
||||
$title = $post->short_title;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class GetNewsSerpTask
|
||||
{
|
||||
public static function handle(Category $category, $country_iso)
|
||||
@@ -76,6 +75,7 @@ public static function handle(Category $category, $country_iso)
|
||||
} catch (Exception $e) {
|
||||
Log::error(json_encode($serp_obj));
|
||||
inspector()->reportException($e);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
use App\Models\Category;
|
||||
use App\Models\NewsSerpResult;
|
||||
use App\Models\SerpUrl;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
|
||||
class ParseNewsSerpDomainsTask
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
use App\Models\Post;
|
||||
use Exception;
|
||||
|
||||
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
|
||||
use LaravelGoogleIndexing;
|
||||
|
||||
|
||||
@@ -29,17 +29,15 @@
|
||||
*/
|
||||
|
||||
Route::get('/now-minute', function (Request $request) {
|
||||
dd(now()->minute);
|
||||
dd(now()->minute);
|
||||
});
|
||||
|
||||
|
||||
Route::get('/indexing', [App\Http\Controllers\Tests\TestController::class, 'indexing']);
|
||||
|
||||
Route::get('/serp-ai-gen', function (Request $request) {
|
||||
AISerpGenArticleJob::dispatch()->onQueue('default')->onConnection('default');
|
||||
AISerpGenArticleJob::dispatch()->onQueue('default')->onConnection('default');
|
||||
});
|
||||
|
||||
|
||||
Route::get('/exponential', function (Request $request) {
|
||||
$post_counts = get_exponential_posts_gen_by_day($request->input('day', 1));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user