I have this code I have written to make my life easier when downloading .torrents, the code is as follows,
$file = 'http://kat.ph/new/';
if($file = file_get_contents($file)) {
// RETURN ALL MAGNET URIS FROM FILE
preg_match_all('/\"magnet\:\?xt\=urn\:btih\:(.*?)\"/x', $file, $magnetURI);
// FOR EACH MAGNET URI RETURNED
foreach($magnetURI[1] as $info) {
echo '<a href="magnet:?xt=urn:btih:' . $info . '">' . $info . '</a><br /><br /><br /><br />';
}
} else {
echo '<strong>FAIL</strong>';
}
It is supposed to match magnet uri links and return them to me in easy to click links, it works on other websites try replacing the file with http://thepiratebay.se/recent/0, but for some reason the website in the example it will not work on?!?
Thanks for your help!
It works for me, try removing the x modifier.
The problem is the file_get_contents() call, apparently kat.ph doesn't like anonymous user agents, if you try to output the $file variable you get a bunch of garbage like:
��}�r�Ʋ�o�)&\ˑ\@�Aڒ�I���X���8Y;�r �! �Ĭ���� ϓ����. ��ey�ĥg�랾��;�u��:��Q6����9�Q�[e��E�~vv��J��Z�٬��=5��n-̒>Ũc�Q�O���ip�[s�(cQ&�&�F<�m������T^oD��e��l 7j���e��]K�K�ţ�ݚ�R/ &YG���x��|��gQS�D��dq�����~�ӌ�32�2HS8�,�B��)z��x'4M�S;uq�ӝ0�NH���Z��OG�e5����Q���zhd4<ŋ�u����Ug��o+�� �H�b�8ɼiFY��f0�C���oR��e*t2��x���Մ.߭L�����,�H��7]��Q�q=1fW� ��"?�!�{O/5��f��IH����[�DO�8Y#i�]i�S�5�R>�,=��SG��_�G��4o�,4�X�XcS� 36����wl�Vr�0D�_I�Ì%�X�*s�Q��$M�s4r| �֎�}$�g`+���0�c#7�'4S&�:|�~� ��$��S�d���y�����8 ��u{���M=P㩑����[oN����?��h`�/ћ}����R|�A � z;�0(�(���Q����=�8���>І[�ㆻF,��]��M����6!��=a4GW�+o���z��o۩s�s ]�0��H�b�����#�/d��Z�/ԕߌ6�P�|�gE�V���dz�ćz���|�zl�ɗ�)��i���e�$�/"��l�ʟ�) ���K�ʗx��Ʉ��:9'H�$�2�ؓP�,�r/��+Fcmq]�P|���n
Try setting the user agent to a known browser (via file_get_contents() HTTP context or CURL).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With