adding new page

This commit is contained in:
Holiienko Roman 2024-01-23 15:45:52 +03:00
parent f65fbda4a7
commit bfcb9cdba2
5 changed files with 44 additions and 7 deletions

View File

@ -15,22 +15,29 @@ class PageScrapper
public function getHTML() public function getHTML()
{ {
$page = file_get_contents($this->url); $page = file_get_contents($this->url);
$strForPregMatch = "/" . "{$this->contentMarker}" . "(.*)<\/div>/isU"; $strForPregMatch = "/" . "{$this->contentMarker}" . "(.*)<\/div>/is";
$arr = []; $arr = [];
$rez = preg_match_all($strForPregMatch, $page, $arr); $rez = preg_match_all($strForPregMatch, $page, $arr);
return $content = $arr[1][0].'</div>';
return $content = $arr[1][0];
} }
public function normalizeURLFile($content) public function normalizeURLFile($content)
{ {
$rez = preg_match_all('/href="(.*)"/isU',$content,$arr); //$content = preg_replace('/<a href="(.*)"/isU', 'https://mkgtu.ru' ,$content );
$rez = preg_match_all('/<a href="(.*)">/isU',$content,$arr);
foreach ($arr[1] as $el) { foreach ($arr[1] as $el) {
if (strpos($el, 'http') !== 0) { if (!str_contains($el, 'https://')){
$content = str_replace($el,'https://mkgtu.ru' . $el,$content); $content = str_replace($el,'https://mkgtu.ru' . $el,$content);
} }
} }
return $content; return $content;
} }
} }

View File

@ -38,7 +38,7 @@
</div> </div>
<div class="col-8"> <div class="col-8">
<a href="postup.php"> <a href="{{ route('spetsialitet-magistratura') }}">
<h4> <h4>
<div <div
class="d-flex justify-content-start align-items-center w-100 h-100 border border-secondary m-1 p-4 buttonHover rounded-2"> class="d-flex justify-content-start align-items-center w-100 h-100 border border-secondary m-1 p-4 buttonHover rounded-2">

View File

@ -0,0 +1,26 @@
@extends('layouts.applicant-layout')
@section('content')
<div class=" fw-bolder fs-1 text-center py-5"> Для поступающих на программы бакалавриата, магистратуры </div>
<div class="container pt-4 d-flex justify-content-center">
<div class="col-10">
@php
use App\Services\PageScrapper;
$pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/", '<div class=["\']content_info["\']>');
$row = $pageScrapper->getHTML();
$content = $pageScrapper->normalizeURLFile($row);
$page = "https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/";
$strForScissors = '/<footer(.*)<\/footer>/isU';
$tmp = preg_match_all($strForScissors, $content, $arr);
$content = str_replace($arr[1],'',$content);
echo $content ;
@endphp
</div>
</div>
@endsection

View File

@ -36,7 +36,7 @@
<div class="col-10"> <div class="col-10">
@php @php
use App\Services\PageScrapper; use App\Services\PageScrapper;
$pageScrapper = new PageScrapper("https://www.mkgtu.ru/postuplenie/web-consultations/", '<div class=["\']content_info["\']>'); $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/podat-dokumenty-onlayn/", '<div class=["\']content_info["\']>');
$row = $pageScrapper->getHTML(); $row = $pageScrapper->getHTML();
$content = $pageScrapper->normalizeURLFile($row); $content = $pageScrapper->normalizeURLFile($row);
echo $content; echo $content;

View File

@ -38,6 +38,10 @@ Route::get('/web-consultations', function () {
return view('menu.abitur.web-consultations'); return view('menu.abitur.web-consultations');
})->name('web-consultations'); })->name('web-consultations');
Route::get('/spetsialitet-magistratura', function () {
return view('menu.abitur.spetsialitet-magistratura');
})->name('spetsialitet-magistratura');
Route::post('/uploadfile', [UploadFileController::class, 'showUploadFile'])->name('uploadfile'); Route::post('/uploadfile', [UploadFileController::class, 'showUploadFile'])->name('uploadfile');
Route::get('/dashboard', function () { Route::get('/dashboard', function () {