0

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. Commented Mar 4, 2011 at 12:24
  • I was so dumb, putting the echo in the wrong loop... Never showing it on screen. Commented Mar 4, 2011 at 12:32

4 Answers 4

2
$content = file_get_contents('http://www.wowhead.com/spell=74217&power');
Sign up to request clarification or add additional context in comments.

Comments

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**][3] -- which means a bit more work...

1 Comment

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...
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.

4 Comments

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...
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).
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?
It depends on the requests and on the server. If the requests can be differentiated from each-other than it can be blocked.
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&amp;power');
} else {
    echo "file_get_contents() won't work";
}
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.