X
X
xuxubla2015-05-05 10:25:49
PHP
xuxubla, 2015-05-05 10:25:49

How to parse a page, with a URL based on a request?

I'm trying to parse an online store using sipmle html dom. In some categories, a large number of products do not fit on one page. Therefore, the goods are displayed on several of 30 pieces.
For example, the first page has the URL */catalogue/2119/ ;
The second has the URL */catalogue/2119/?SECTION_ID=2119&PAGEN_20=2 .
As a result, the first page is always parsed instead of the required page (ie */catalogue/2119/ ).
Does anyone have any idea why this might be? And how to get rid of it?
I add the source code:

<?php
include_once 'simple_html_dom.php';
$url='http://www.felix.ru/catalogue/4675/';
$html = new simple_html_dom();
$html2 = new simple_html_dom();
$html -> load_file($url);
foreach ($html -> find('div.Pages a[!class]') as $a3) {
                        $step4 = 'http://www.felix.ru' . $a3->href;
                        $html2 -> load_file($step4);
                        echo $step4 . '<br>';
                        foreach ($html2 -> find('a.ItemLink') as $a4) {
                            echo '------' . $a4->href . '<br>';
                            $step5 = $url . $a4->href;
                        }
}
$time2 = time()-$time1;

Now I separately did the parsing of the desired page, surprisingly everything works. This confused me even more.
<?php
include_once 'simple_html_dom.php';
$url='http://www.felix.ru/catalogue/4675/?SECTION_ID=4675&PAGEN_24=4';
$html = new simple_html_dom();
$html -> load_file($url);
foreach ($html -> find('a.ItemLink') as $a4) {
    echo '------' . $a4->href . '<br>';
    $step5 = $url . $a4->href;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Vsk, 2015-05-05
@viktorvsk

Because the parser itself does not know how to guess what you need to go through the pages?)
Where is the code?

M
Mike, 2015-05-05
@Mike77

well, write a new parser
https://packagist.org/packages/symfony/dom-crawler
https://packagist.org/packages/anlutro/curl

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question