I'm trying to get http://www.wowhead.com/spell=74217&power into a variable so that I can parse it as I like and save to my DB. I couldn't even get to echo it, I might be brain lagged though.
Asked
Active
Viewed 386 times
0
-
I'm already using file_get_contents to get other parts of the data, but weirdly I'm lost on getting this one and basically echo'ing... I just want to echo file_get_contents('http://blabla.com/blabla&power'); And it would echo nothing. – Weptile Mar 04 '11 at 12:24
-
I was so dumb, putting the echo in the wrong loop... Never showing it on screen. – Weptile Mar 04 '11 at 12:32
4 Answers
2
$content = file_get_contents('http://www.wowhead.com/spell=74217&power');

phihag
- 278,196
- 72
- 453
- 469
2
Depending on your configuration, you might use file_get_contents
, to open a remote file via its URL, and get the corresponding content.
You'll need the allow_url_fopen
directive to be enabled.
If it's not enabled, you'll probably have to fall back to curl -- which means a bit more work...

Pascal MARTIN
- 395,085
- 80
- 655
- 663
-
I'm already using file_get_contents to get other parts of the data, but weirdly I'm lost on getting this one and basically echo'ing... – Weptile Mar 04 '11 at 12:22
1
For me, the following code does the job:
var_dump(file_get_contents("http://www.wowhead.com/spell=74217&power"));¬
But I would use an HTTP client library to do it.
Maybe your configuration disabled it, check allow_url_fopen
, it must be turned on to be able to use URLs in file_get_contents
.

KARASZI István
- 30,900
- 8
- 101
- 128
-
I'm already using file_get_contents to get other parts of the data, but weirdly I'm lost on getting this one and basically echo'ing... – Weptile Mar 04 '11 at 12:23
-
Then check the HTTP traffic with a sniffer tool, for e.g. `tcpdump` or use an HTTP client library as I mentioned. Maybe the server is blocking your client (too many connections). – KARASZI István Mar 04 '11 at 12:24
-
I don't suppose so as I'm already using another script from the same site. Would it still be possible that I'm blocked only for this request and let for using the other scripts form same site? – Weptile Mar 04 '11 at 12:30
-
It depends on the requests and on the server. If the requests can be differentiated from each-other than it can be blocked. – KARASZI István Mar 04 '11 at 12:33
0
Write the ampersand as & in the URL then it returns the complete page.
<?php
ini_set("error_reporting", E_ALL);
ini_set('display_errors', 1);
if (ini_get("allow_url_fopen")) {
echo $content = file_get_contents('http://www.wowhead.com/spell=74217&power');
} else {
echo "file_get_contents() won't work";
}
?>

initall
- 2,385
- 19
- 27