Questions tagged [domcrawler]

The DomCrawler is a Symfony component for PHP which eases DOM navigation for HTML and XML documents.

The DomCrawler component eases DOM navigation for HTML and XML documents and is part of the the Symfony PHP components.

The filter() function accepts the jQuery Selector Syntax and eases the selection of HTML tags and attributes.

Documentation

179 questions
3
votes
1 answer

How to filter children node values from parent div where style = "..." using Goutte and Symfony DomCrawler?

I am trying to scrape the quotes from a given wikiquote page using the php package Goutte, which wraps the Symfony Components: BrowserKit, CssSelector and DomCrawler. However there are certain quotes which I do not want in my result set, the quotes…
Fetus
  • 985
  • 2
  • 12
  • 23
3
votes
1 answer

Select an option from dropdown box using DOMCrawler in PHP

I am using DOMCrawler in PHP. I have the HTML below. I need to be able to select the option "Text1", and submit the form. I have the following code but I can't seem to make it work... What am I doing wrong? use Goutte\Client; $client = new…
Prem
  • 65
  • 3
  • 7
3
votes
2 answers

How to update selected Dom element with DomCrawler component of symfony?

How to update selected Dom element with DomCrawler component of symfony? $crawler->filter("table.positions")->addHtmlContent(""); $crawler->filter('.position')->html(); // InvalidArgumentException: The current…
Ivan M
  • 330
  • 2
  • 9
2
votes
2 answers

Symfony Dom-crawler not found in laravel 9

So i have this url $url = "localhost:8000/vehicles" that i want ot fetch through a cron job but the page returns html so i wanna use symfony dom crawler to get all the vehicles instead of regex At the top of my file i added use…
w3_
  • 64
  • 1
  • 1
  • 14
2
votes
1 answer

Goutte - Get list with date on top and title below

I am using "fabpot/goutte": "^4.0",. I am trying to get from the site the date and the release in an array. Please find my runnable example:
Carol.Kar
  • 4,581
  • 36
  • 131
  • 264
2
votes
1 answer

How can I iterate over DomCrawler results and search for specific elements

Consider a webpage with multiple divs with class day. I have a list of those divs thanks to DOMCrawler: $crawler = new Crawler($html); $days = $crawler->filter('.day'); Those day divs contain an array, and I need to iterate over each row, and then…
Louis 'LYRO' Dupont
  • 1,052
  • 4
  • 15
  • 35
2
votes
1 answer

Encoding korean for crawlling with got

I am trying to crawl a web site with got library. I write a simple code. import got from 'got'; async function test(){ const data = await got('https://dhlottery.co.kr/store.do?method=topStore&pageGubun=L645', { encoding: 'utf8'}); …
kyun
  • 9,710
  • 9
  • 31
  • 66
2
votes
1 answer

DomCrawler filterXpath not always giving full URL

For my project, I'm using domcrawler to parse pages and extract images. Code: $goutteClient = new Client(); $guzzleClient = new GuzzleClient(array( 'timeout' => 15, )); $goutteClient->setClient($guzzleClient); try { $crawler =…
Felix
  • 2,532
  • 5
  • 37
  • 75
2
votes
1 answer

DomCrawler get element contents after specific element

I'm trying to get an element's contents that comes right after another element. Here's some example code:
2010
2011
2
votes
2 answers

DomCrawler is removing part of the html

When I get the content without DomCrawler, I get the html with custom tags like @click but when I use $this->crawler->filter('something')->html() DomCrawler is removing my @click tags. Here an example without using DomCrawler: And here is using…
user2824729
2
votes
1 answer

how to use :not selector in symfony's css selector component

I want to simulate what I can achieve in jQuery by $('.someClass:not(.hidden)') I tried below code. $crawler->filter('someClass:not(.hidden)') but it seems not working
Hatem Said
  • 333
  • 1
  • 13
2
votes
0 answers

Unable to get text from HTML DOM using Symfony DomCrawler

I am crawling an HTML using symfony DomCrawler. I am providing the snippet of HTML that I need to fetch:

Account: 1234567
Type 987654

Now I need 987654 text, but I…
Sharad Soni
  • 378
  • 1
  • 5
  • 18
2
votes
0 answers

How to use :not CSS Selector to filter out Symfony DomCrawler instance?

Here is the html snippet from where I want to extract all the link elements with commas but not the span elements inside the span class tl laravel, goutte,
coolsaint
  • 1,291
  • 2
  • 16
  • 27
2
votes
1 answer

Symfony DOMCrawler break from each

I'm trying to filter my html with DOMCrawler, but I need to break if result is found. Is it possible to break from each? Or how can I get $node->text(); if I use foreach? Or it's not possible? HTML:
user3703456
2
votes
1 answer

How to get the form object in PHPUnit

I am testing with the PHPUnit. However it shows error. whitebear$ phpunit -c app src/Acme/MemberBundle/Tests/Controller/DefaultControllerTest.php PHPUnit 4.8.35 by Sebastian Bergmann and contributors. E Time: 1.18 seconds, Memory: 90.25MB There…
whitebear
  • 11,200
  • 24
  • 114
  • 237
1
2
3
11 12