Reputation: 23
I have no clue what the solution might be. I simply cannot get the html file of this Charizard, I don't get any response even though the link is correct. Bulbasaur is working fine, but I want this lovely Charizard...
include("simple_html_dom.php");
$html = file_get_html('https://bulbapedia.bulbagarden.net/wiki/Charizard_(Pok%C3%A9mon)');
$html2 = file_get_html('https://bulbapedia.bulbagarden.net/wiki/Bulbasaur_(Pok%C3%A9mon)');
echo $html;
echo $html2;
Does this page have any protection or is Charizard only harder to catch? I'd appreciate if you are able to help me with this.
Jonas :)
Upvotes: 2
Views: 1269
Reputation: 3409
There are two problems here:
MAX_FILE_SIZE
(defined in simple_html_dom.php
)To solve the first problem, edit simple_html_dom.php
and change define('MAX_FILE_SIZE', 600000);
to use a bigger number.
As a workaround for the second problem, pass correct parameters to file_get_html
, and by that I mean to pass 0
for $offset
:
$html = file_get_html('https://bulbapedia.bulbagarden.net/wiki/Charizard_(Pok%C3%A9mon)',
false,
null,
0); // this last one is the offset
var_dump($html);
Alternatively you can use the forked version of the library.
Upvotes: 3
Reputation: 54984
I'm going to suggest an alternative library because II don't think you will get this with simple_html_dom:
include 'advanced_html_dom.php';
$html = file_get_html('https://bulbapedia.bulbagarden.net/wiki/Charizard_(Pok%C3%A9mon)');
echo $html->find('h1', 0)->text() . PHP_EOL;
echo $html->find('big a[title*="Pokédex number"]', 0)->text() . PHP_EOL;
This gives:
Charizard (Pokémon)
#006
Upvotes: 0
Reputation: 177
Since i haven't found the file_get_html()
in the php docs, maybe you prefer using file_get_contents(url)
instead.
Upvotes: -1