Add xl file
This commit is contained in:
57
database/seeders/TopAiToolSeeder.php
Normal file
57
database/seeders/TopAiToolSeeder.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\UrlToCrawl;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class TopAiToolSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
|
||||
// Path to the text file
|
||||
$filePath = resource_path('data/domains/topaitools-xl.txt');
|
||||
|
||||
// Check if the file exists
|
||||
if (file_exists($filePath)) {
|
||||
// Open the file for reading
|
||||
$file = fopen($filePath, 'r');
|
||||
|
||||
if ($file) {
|
||||
while (($url_link = fgets($file)) !== false) {
|
||||
|
||||
$domain = get_domain_from_url($url_link);
|
||||
|
||||
// dump($url_link);
|
||||
|
||||
$url_link = remove_query_parameters($url_link);
|
||||
|
||||
// dd($url_link);
|
||||
|
||||
$url_to_crawl = UrlToCrawl::where('url', $url_link)->first();
|
||||
|
||||
if (is_null($url_to_crawl)) {
|
||||
$url_to_crawl = new UrlToCrawl;
|
||||
$url_to_crawl->domain = $domain;
|
||||
$url_to_crawl->url = $url_link;
|
||||
$url_to_crawl->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (! feof($file)) {
|
||||
dump('Error: unexpected fgets() fail');
|
||||
}
|
||||
|
||||
// Close the file
|
||||
fclose($file);
|
||||
}
|
||||
} else {
|
||||
dump('The file does not exist.');
|
||||
}
|
||||
}
|
||||
}
|
||||
3570
resources/data/domains/topaitools-xl.txt
Normal file
3570
resources/data/domains/topaitools-xl.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user