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.
2
-
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('blabla.com/blabla&power'); And it would echo nothing.Weptile– Weptile2011-03-04 12:24:37 +00:00Commented Mar 4, 2011 at 12:24
-
I was so dumb, putting the echo in the wrong loop... Never showing it on screen.Weptile– Weptile2011-03-04 12:32:51 +00:00Commented Mar 4, 2011 at 12:32
Add a comment
|
4 Answers
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**][3] -- which means a bit more work...
1 Comment
Weptile
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...
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.
4 Comments
Weptile
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...
KARASZI István
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).Weptile
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?
KARASZI István
It depends on the requests and on the server. If the requests can be differentiated from each-other than it can be blocked.
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";
}
?>