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
2
votes
1 answer

DOM Crawler and The current node list is empty - how to get list

I need help with DOM Crawler in Symfony 3.2. Here is my code: $html = file_get_contents('http://www.wakacje.pl/wczasy/peru/'); $crawler = new Crawler($html); $crawler = $crawler->filter('#gridWithPagination > div > div')->each(function (Crawler…
AppleandPear
  • 51
  • 1
  • 11
2
votes
2 answers

Join URLs in symfony/goutte

I have a Goutte/Client (goutte uses symfony for the requests) and I would like to join paths and get a final URL: $client = new Goutte\Client(); $crawler = $client->request('GET', 'http://DOMAIN/some/path/') // $crawler is instance of…
Dekel
  • 60,707
  • 10
  • 101
  • 129
2
votes
2 answers

Symfony2 InvalidArgumentException: The current node list is empty

I'm doing functional testing and I am getting the error InvalidArgumentException: The current node list is empty This is my code public function testThis(){ $requestContent = [ 'val1' => '324343', 'valname' => '"Benjamin"', …
momori14
  • 169
  • 1
  • 2
  • 14
2
votes
1 answer

How to check a site after redirection? DomCrawler. Functional Testing

How to properly make assertion after redirection? $crawler = $client->submit($form); $client->followRedirect(); //$response = $client->getResponse()->getContent(); $this->assertTrue($crawler->filter('html:contains("foo")')->count() > 0); Debugger…
user6827096
  • 1,186
  • 1
  • 11
  • 26
2
votes
1 answer

DomCrawler. How to click button? "Unable to navigate from a "button" tag."

I got form: and want to click it: // $link =…
user6827096
  • 1,186
  • 1
  • 11
  • 26
2
votes
0 answers

Goutte PHP does not submit form without submit input

I have a form without a submit input:
The form submits to…
jsrosas
  • 103
  • 2
  • 14
2
votes
0 answers

Symfony DomCrawler Equivalent in Python

Are there any python libraries out there that work like Symfony's DomCrawler? I would like to use CSS selectors in order to extract data from some HTML. The functionality I'm most interested in would be something similar to this snippet of…
RattleyCooper
  • 4,997
  • 5
  • 27
  • 43
2
votes
1 answer

Break out of the each method in Symfony's DomCrawler

I am trying to filter through the specific element and then once the text is found, I want to record the position and break out of the each method. But I cannot break out of it I get the PHP error Cannot break/continue 2 levels Here's the current…
zen
  • 1,115
  • 3
  • 28
  • 54
2
votes
1 answer

DomCrawler FilterXPath Query

I'm have some html such as below: ... other html stuff ...
Kenny
  • 2,124
  • 3
  • 33
  • 63
2
votes
5 answers

css don't select child elements

Lets say I have the html as below:

This is a test Some more explanation

How can I filter the text…
sanders
  • 10,794
  • 27
  • 85
  • 127
2
votes
1 answer

Call to undefined method Symfony\Component\DomCrawler\Crawler::rewind()

I was using the Yii2 DynamicForms extension to create dynamic fields without problems, but today when I run composer update i'm receiving the following error: Call to undefined method Symfony\Component\DomCrawler\Crawler::rewind() The error is…
jflizandro
  • 622
  • 1
  • 8
  • 16
2
votes
0 answers

DOMCrawler: how to select all links in "a" tag and in "area" tag

I'd like to get a list of all the links present on a page. Some of those links are in an area tag. So I do this to get a full list of all links: // Get the a links $links = $crawler->filter('a')->links(); // Append the links in area tag (clicakble…
Aerendir
  • 6,152
  • 9
  • 55
  • 108
2
votes
3 answers

Whats the most efficient/nicest way to extract a text value from a HTML tag using Symfony DOM Crawler?

Given the following HTML code snippet:
large size
I'm looking for the best way to extract the string "large" using Symfony's Crawler. $crawler = new Crawler($html); Here I could use…
haxpanel
  • 4,402
  • 4
  • 43
  • 71
2
votes
2 answers

extract untagged elements with symfony dom crawler

How to extract untagged elements with symfony dom crawler. For example in the sample html below I want to extract Hello World. titleHello WorldSub-Title
This is just stuff
M Sh
  • 429
  • 2
  • 4
  • 11
2
votes
1 answer

Symfony DomCrawler

I use DomCrawler in Symfony. $variable = 'value'; $crawler->filter('table > tr')->each( function ($node, $i) { // $variable; } ); I try to access the variable inside the function but I get the error: Undefined variable. How can I…
Yssn
  • 361
  • 1
  • 5
  • 15
1 2
3
11 12