0

i want to read the sourcecode of another webpage and receive the following error using file_get_contents in PHP:

Warning: file_get_contents(url is here) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in file_get.php

How is this possible and is there a solution to work around this?

Thanks.

2
  • 3
    Food for thought: You won't get any response if you don't post your actual code. Actually that's not entirely true, you will get a response, some of which will end up as being "downvotes", which I for one, did NOT downvote but you can expect more till you do. Jul 21, 2013 at 5:56
  • You could always try to use an iframe to "display" content, but that's not always a sure fire way. FYI: Google and other sites as such won't show up using iframes, if that's your intention. Jul 21, 2013 at 6:04

1 Answer 1

3

The error message sums it up nicely:

HTTP/1.1 403 Forbidden

You do not have permission to access that page. It is controlled by the host you're trying to scrape.

For more information, see HTTP 403 on Wikipedia.

1
  • 'tis the "hard & harsh reality" of it all. (Oh, the humanity). Jul 21, 2013 at 6:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.