Extrage date in PHP din Sir JSON
Scris: Sâm Feb 16, 2013
Buna am o problema cu variabila in postul anterior cu developer youtube am inteles cum se extrag datale insa am intampinat o problema la un nou script care nu are variabila info in fata, precum avea cealalta extragere.
Am incercat sa modific partial codul si mia rezultat:
Dar nu imi apare nimic, nu inteleg cum sa extrag
Titlul, edclosure_url si Seeds din adresa url:
isohunt.com/js/json.php?ihq=Armo%202
Un altfel de rezultat incepe cam asa:
Unde am gresit in scriptul de mai sus?
Am incercat sa modific partial codul si mia rezultat:
Cod: Selectaţi tot
<?php
$url = 'http://isohunt.com/js/json.php?ihq=ubuntu&start=21&rows=20&sort=seeds';
$content = file_get_contents($url);
if(preg_match('/{(.*?)}/i', $content)) {
print 'Titlu: ';
print $item['title'];
print '<br>';
print 'URL: ';
print $item['enclosure_url'];
print 'Parteneri:';
print $item['Seeds'];
print '<br>';
}
?>
Titlul, edclosure_url si Seeds din adresa url:
isohunt.com/js/json.php?ihq=Armo%202
Un altfel de rezultat incepe cam asa:
Cod: Selectaţi tot
{"title": "isoHunt > All > Armo 2",
"link": "http://isohunt.com",
"description": "BitTorrent Search > All > Armo 2",
"language": "en-us",
"category": "All",
"max_results": 1000,
"ttl": 15,
"image": {"title": "isoHunt > All > Armo 2",
"url": "http://isohunt.com/img/buttons/isohunt-02.gif",
"link": "http://isohunt.com/",
"width": 157,
"height": 45},
"lastBuildDate": "Sat, 16 Feb 2013 17:45:02 GMT","pubDate": "Sat, 16 Feb 2013 17:45:02 GMT","total_results":24, "censored":0, "items": {"list": [{"title":"The Last Emperor","link":"http:\/\/isohunt.com\/torrent_details\/133610293\/Armo+2?tab=summary","guid":"133610293","enclosure_url":"http://ca.isohunt.com/download/133610293/Armo+2.torrent","length":121023496,"tracker":"tracker.openbittorrent.com","tracker_url":"http:\/\/tracker.openbittorrent.com:80\/announce","kws":"Soundtracks","exempts":" ... 03. Ryuichi Sakamoto - Where Is <b>Armo</b>.mp3","category":"Pics","original_site":"www.mininova.org","original_link":"http:\/\/www.mininova.org\/get\/2994880","size":"115.42 MB","files":18,"Seeds":3,"leechers":0,"downloads":10,"votes":0,"comments":1,"hash":"b064249a32a4ebf8725a6bef8b8f4a73a979c73d","pubDate":"Mon, 28 Sep 2009 04:00:50 GMT"}, ....si asa mai departe