I am trying to retrieve data from tags on a website using the symfony crawler link.
foreach ($tables as $table) {
$response = $this->client->get($url, [
'http_errors' => false,
]);
$body = $response->getBody()->getContents();
$crawler = new crawler($body);
$version = $crawler->filter('tr > td');
$i = 1;
while (true) {
if (something) {
break;
}
$tableVersions[$table] = preg_split('/\r\n|\r|\n/', $version->eq($i + 1)->text());
$i++;
}
}
return $tableVersions;
In windows this works, preg_split nicely separates the words that I wanted to break, and put them separately in an array.
When I print $version->eq($i + 1)->text()in the windows, it looks like this:
word1
word2
word3
On linux, it simply puts all non-delimited lines in the first element of an array like this.
word1word2word3
this is the same code. So I guess in windows that the crawler returns new line feeds, but on Linux it doesn't? How should I get a good array of all the tags in an html page and then filter them out?
source
share