包含散列信息的file_get_contents [英] file_get_contents with Hash Information Included

查看:71
本文介绍了包含散列信息的file_get_contents的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了很多方法来尝试获取url的内容,其中哈希会影响输出。我真的不知道如何解释它,但这里有一个例子...

做:

  echo file_get_contents('test.com/whatever.php?t1=1&t2=2#this'); 

将返回与以下相同的结果:

  echo file_get_contents('test.com/whatever.php?t1=1&t2=2'); 

即使我在浏览器中浏览它,它也会有所作为。当然,上面的网址并不是我正在使用的实际网址,但我希望您能明白。



我尝试过的方法:



CURL:

  $ ch = curl_init(); 
curl_setopt($ ch,CURLOPT_URL,$ url);
curl_setopt($ ch,CURLOPT_HEADER,0);
curl_exec($ ch);
curl_close($ ch);

file_get_contents:

 的file_get_contents($网址); 





  //不知道我把代码放在哪里。 

这些都是我尝试过的所有东西,除了这里之外并不知道下一步该去哪里。我真的不确定这是否可能,但我希望它。



感谢您的帮助,sh042067。

解决方案

散列不会发送到服务器。哈希部分通常只能被浏览器访问。您可能会看到某种AJAX检索,因此您需要找出正在调用的实际URL并使用它。你可以为此使用Firebug。



找到参考资料: http:// en .wikipedia.org / wiki / Fragment_identifier



请检查这些

为什么URL的哈希部分不在服务器端?



我可以在服务器端应用程序(PHP,Ruby,Python等)上读取URL的哈希部分吗?


I have tried many methods to try and get the contents of a url, with the hashes effecting the output. I really am not sure how to explain it, but here's an example...

Doing:

echo file_get_contents('test.com/whatever.php?t1=1&t2=2#this');

Will return the same results as:

echo file_get_contents('test.com/whatever.php?t1=1&t2=2');

Even though if I navigate to it in my web browser, it will make a difference. Of course the urls above aren't the actual one's that I am using, but I hope you get the point.

Things I have tried:

CURL:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);

file_get_contents:

file_get_contents($url);

fread:

//don't know where I put the code.

Those are all the things I have tried, and don't really know where to go next besides here. I'm really not sure if this is even possible, but I hope it is.

Thanks for any help, sh042067.

解决方案

Hashes are not sent to the server. The hash part is usually only accessed by the browser. Yo're probably seeing some kind of AJAX retrieval in action so you'll need to find out the actual URL that is being called and use that instead. You could use Firebug for this.

Found the references : http://en.wikipedia.org/wiki/Fragment_identifier

Check these too

Why the hash part of the URL is not in the server side?

Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)?

这篇关于包含散列信息的file_get_contents的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆