Question

Does anyone have any examples of how to scrape meta tags using QueryPath? I'm trying to get the content of the following:

<meta content="London" property="og:locality">

I recently switched from simple_html_dom which was easy to use, well documented BUT slow. In comparison QueryPath is faster, but has crap documentation and very few questions on Google / SO.

Was it helpful?

Solution

Just use:

$locality = qp($html)->find('meta[property="og:locality"]')->attr("content");

Where $html is the html page you want to parse. $locality would have the value London based on your given example.

Here's a good general tutorial: http://www.ibm.com/developerworks/web/library/os-php-querypath/index.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top