我现在从泰卢固语站点获取数据当我从网站上获取英语内容时我可以毫无问题地获取它但是假设内容是泰卢固语(印度的泰米尔语)
它不会返回正确的字符串。
代码:
<?php
//
include "simple_html_dom.php";
// Get news from telugu site
$url = "http://www.123telugu.com/category/mnews";
$html = file_get_html($url);
$divs = $html->find('div.leading');
$result = array();
$status = FALSE;
$i = 0;
foreach ($divs as $d) {
$status = TRUE;
$title = $d->find('a', 0)->plaintext;
$result[$i]['Title'] = $title;
$link = $d->find('a', 0)->href;
$result[$i]['Link'] = $link;
$title = trim(mysql_real_escape_string($title)); // code for title
$html = file_get_html($link);
// code for image
$image = '';
foreach ($html->find('div.post-content') as $im) {
$image = $im->find('img', 0)->src; // code for image
}
$image = trim(str_replace('//', '', $image));
$result[$i]['Image'] = $image;
// code for content
$content = '';
foreach ($html->find('div.post-content p') as $co) {
$content.= $co->plaintext; // code for content
}
$result[$i]['Content'] = $content;
$i++;
}
echo json_encode(array('Status' => $status, 'Data' => $result));