0

I am trying to do the following

$url = "http://halo-video.com/drama/ha"; $data = file_get_contents($url); echo $data; 

it give me a blank page or a 500 internal error, I tried load the site with my computer, and its load fine.

4
  • Check your error logs to determine the error and report back. Commented Oct 25, 2013 at 20:53
  • I tried print and it show a 500 internal error, but the site load fine with my com Commented Oct 25, 2013 at 21:03
  • @user1777711 There's obviously something wrong with the kissanime.com domain because I replaced the URL with Google's and it worked fine (code). Commented Oct 25, 2013 at 21:08
  • @Fred-ii- But i can access it using my computer but not by php curl Commented Oct 26, 2013 at 5:31

3 Answers 3

1

although reason could be different but my code (similar to yours) works fine so just append these lines into yours at appropriate places,

$useragent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7"; curl_setopt($s,CURLOPT_AUTOREFERER, true); curl_setopt($s,CURLOPT_FOLLOWLOCATION, true); curl_setopt($s,CURLOPT_MAXREDIRS, 5); curl_setopt($s,CURLOPT_RETURNTRANSFER, true); curl_setopt($s, CURLOPT_HEADER, true); 
Sign up to request clarification or add additional context in comments.

2 Comments

The response should not be Object move to here, if you access using your computer, the response is different.
1

EDIT:

Ok, this was bugging me so figured out a fix.

$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://kissanime.com/Anime/Karneval'); curl_setopt($ch, CURLOPT_USERAGENT, 'myuseragent'); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_REFERER, "http://www.test.com"); $html = curl_exec($ch); curl_close($ch); echo $html; 

This code works and fixed the redirect errors I was getting. Happy content grabbing.

1 Comment

But the original page content is not Object moved to here. If you try access by your window its different.
0

Use file() instead of file_get_contents()

$url = "http://kissanime.com/Anime/Karneval"; $data = file($url); echo htmlspecialchars($data); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.