spekulatius / PHPScraper

A universal web-util for PHP.

Home Page:https://phpscraper.de

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

links from div

zigou13 opened this issue · comments

Hello, I have a problem, I want to have all the links from // * [@ id = "content"] 'how do I do?

Hey @zigou13,

have you tried using $scraper->filter('//*[@id="content"]')?

Cheers,
Peter

Yes it works but after I can not get the a href out of the id ="content"

public function content() {
$content = $this->filterExtractAttributes('//*[@id="content"]', ['_name', '_text','_href','_alt']);
return $content;
}

$content = $web->content;

Return
Allemagne (43)
Angleterre (79)
Autriche (8)
Belgique (19)
Biélorussie (1)

is not link a href

It's good
$content = $this->filterExtractAttributes('//*[@id="content"] //a', ['_name', '_text','href','alt']);

[3] => Array ( [0] => a [1] => Allemagne [2] => /my-link [3] => )

Ah, I see, you are pre-selecting the element using the div and the want the a-tags below. Everything is sorted now? :)

yes thank you, I continue my parsing

Awesome, great it's useful!

I'll close this for now. Feel free to open a new one or reply if anything else comes up 👍