我无法从链接中获取内容 http://raindrops.in/ainvvy/view/527a727a4251df44558b4567
我尝试了帖子How do I get the HTML code of a web page in PHP?
中提供的file_get_contents和curl请帮助我获取链接的内容。我想将它保存到变量中。
答案 0 :(得分:1)
以下代码对我有用。
echo @file_get_contents('http://raindrops.in/ainvvy/view/527a727a4251df44558b4567');
确保您的php.ini文件中有 allow_url_fopen = On
答案 1 :(得分:1)
如果您的php.ini文件中没有allow_url_fopen = on
,则可以使用“cUrl”来获取远程页面。
cUrl Manual Page
答案 2 :(得分:1)
好吧,这个网站在很大程度上依赖于AJAX的内容,所以只获得源代码(你用cUrl或file_get_contents做的只会给你一个空页。
您有2个选择来获取“真实”内容(播放器演示):
卷曲'http://raindrops.in/rest/ainvvy/527a727a4251df44558b4567' - H'Cookie:__ utma = 161727679.1871000365.1388669242.1388669242.1390391663.2; __utmb = 161727679.3.10.1390391663; __utmc = 161727679; __utmz = 161727679.1390391663.2.2.utmcsr = stackoverflow.com | utmccn =(referral)| utmcmd = referral | utmcct = / questions / 20967366 / not-able-to-the-contents-of-url'-H' Accept-Encoding:gzip,deflate,sdch'-H'Accept-Language:en-US,en; q = 0.8,fr-FR; q = 0.6,fr; q = 0.4'-H'User-Agent:Mozilla / 5.0(X11; Linux x86_64)AppleWebKit / 537.36(KHTML,与Gecko一样)Chrome / 32.0.1700.77 Safari / 537.36'-H'接受:application / json,text / javascript, / ; q = 0.01'-H'Referer:http://raindrops.in/ainvvy/view/527a727a4251df44558b4567'-H'X-Requested-With:XMLHttpRequest'-H'连接:keep-alive'-H'Cache-Control:max-age = 0' - 压缩)