Reputation: 23
I am trying to use Goutte to get the contents of a page, when veiwing the source there is a script that I want to get the contents of all the code in ...
<script type='application/ld+json'>
"@context" : "http://schema.org",
"@type" : "LocalBusiness",
"name" : "Example",
</script>
I am using something like this, which works for html elements but not the script element.
$crawler->filter('.main_content')->each(function ($node) {
Once I have got the contents, I want to explode it by each element.
Any idea's?
Upvotes: 1
Views: 1459
Reputation: 11
This works well for me:
$crawler->filterXpath('//script[@type="application/ld+json"]');
docs: https://symfony.com/doc/current/components/dom_crawler.html
Upvotes: 1