Answer the question
In order to leave comments, you need to log in
PHP parser. How does the copied data display via links on individual pages?
I made a parser that copies the titles from each post on the main page of the site. The parser also copies links to each publication, this is in order to further parse the content of publications, and of course the content of publications is also parsed by the parser.
As a result, on the screen I got a list of headings and under the headings information that was inside the article, that is, the content of the publication that I parsed for links.
How can I make each title automatically become a link and the information that I parsed is displayed on this link, that is, on a new page?
Parser code:
<?php
header('Content-type: text/html; charset=utf-8');
require 'phpQuery.php';
function parseArticle($url){
$file = file_get_contents($url);
$doc = phpQuery::newDocument($file);
$text = $doc->find('.post-body')->html(); //парсинг содержания публикаций (по ссылками)
print_arr($text);
}
function print_arr($arr){
echo '<pre>' . print_r($arr, true) . '</pre>';
}
$url = 'http://goruzont.blogspot.com/';
$file = file_get_contents($url);
$doc = phpQuery::newDocument($file);
foreach($doc->find('.blog-posts .post-outer .post') as $article){
$article = pq($article);
$text = $article->find('.entry-title a')->html(); //парсинг заголовков
print_arr($text);
$texturl = $article->find('.entry-title a')->attr('href'); //парсинг ссылок
parseArticle($texturl);
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question