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
9
votes
2 answers

How to parse html table to array with symfony dom crawler

I have html table and I want to make array from that table $html = '
satu dua
tiga empat
My array must look like this array( array( "satu", …
Arif Hidayat
  • 115
  • 1
  • 1
  • 8
9
votes
6 answers

Symfony 2 Dom Crawler: how to get only text() in Element

Using Dom Crawler to get only text (without tag). $html = EOT<<<
Get Description Coucu
EOT; $crawler = new Crawler($html); $crawler = $crawler->filter('.coucu')->first()->text(); output: Get…
Tue Vo
  • 323
  • 2
  • 3
  • 14
8
votes
3 answers

Goutte - Get inner values from $crawler->filter()

I am using PHP 7.1.33 and "fabpot/goutte": "^3.2". My composer file looks like the following: { "name": "ubuntu/workspace", "require": { "fabpot/goutte": "^3.2" }, "authors": [ { "name": "admin", …
Carol.Kar
  • 4,581
  • 36
  • 131
  • 264
5
votes
1 answer

Getting a data-attribute with DomCrawler

Is it possible to get the data with DomCrawler? $cralwer->attr('class') gets me the node's class attribute, but ->attr('data-something') or ->attr('something') always results in null. Edit: tagging PHP also because I tried while manipulating the…
Jean-Philippe Murray
  • 1,208
  • 2
  • 12
  • 34
5
votes
2 answers

How to Get text from element, excluding some other elements inside that

I'm using domCrawler in symfony framework. I crawled contents from html using it. Now I need to get the text inside an element with ID. I'm able to fecth the text by using the code below: $nodeValues =…
arun
  • 3,667
  • 3
  • 29
  • 54
5
votes
1 answer

How to extract data with Goutte Crawler?

This code, returned hrefs to content, now I want to extract content form this hrefs and sent it to my view. Name divs which I need to extract:
Contact:
Jensej
  • 1,255
  • 6
  • 21
  • 33
4
votes
1 answer

How to test form submission with wrong values using Symfony crawler component and PHPUnit?

When you're using the app through the browser, you send a bad value, the system checks for errors in the form, and if something goes wrong (it does in this case), it redirects with a default error message written below the incriminated field. This…
Christophe
  • 73
  • 5
4
votes
1 answer

Symfony DomCrawler how to insert html after some element?

The HTML content

This is title

Js Lim
  • 3,625
  • 6
  • 42
  • 80
4
votes
0 answers

Symfony crawler returns data with CR LF in windows but not in linux

I'm trying to get data from tags on a website by using the symfony crawler link this. foreach ($tables as $table) { $response = $this->client->get($url, [ 'http_errors' => false, ]); $body =…
jonasG
  • 41
  • 2
4
votes
0 answers

Laravel 5.4 PHPunit testing Unreachable field (used name/id attirbute)

I'm testing Laravel according to Laracast/Integreted following exactly as name attribute shown there. And one form in per page. I have some unit test on a form where first two field is reached but on third field which is a textarea with…
4
votes
1 answer

Can not fetch value of an element using Symfony Dom Crawler

I am fetching a URL using guzzle POST method . its working and returning the page that I want . but the problem is when I want to get the value of an input element in a form in that page, the crawler returns nothing . I don't know why .…
Ramin Omrani
  • 3,673
  • 8
  • 34
  • 60
4
votes
2 answers

Symfony DomCrawler with XML and XPath

I am trying to get all the title elements and save them in an array. XML: 1 Example 1 2 2
allnex
  • 335
  • 3
  • 12
3
votes
1 answer

Goutte extract text with tags

While trying to learn and use Goutte to scrape websites for descriptions, it does retrieve text but removes all tags (i.e.
). Is there a way to retrieve the values of all text within the div, including html tags? Or is there an easier…
Arran
  • 156
  • 3
  • 15
3
votes
0 answers

Symfony DomCrawler: get caption inside link

I'm trying to get the caption inside tag. For example: Nice will output Nice. I'm using Symfony DomCrawler. This is what I tried: $crawler = Goutte::request('GET', 'somelink'); $crawler->filter('a')->each(function…
TheUnreal
  • 23,434
  • 46
  • 157
  • 277
3
votes
1 answer

Symfony Dom Crawler missing closing tag in template

I use the Symfony DOM Crawler to read and save an HTML document containing a template. But the closing HTML tags are missing in the template. Here is an example:
Nicolas Hefti
  • 303
  • 2
  • 9
1
2 3
11 12