【问题标题】:PHP function not recognize different languagePHP函数无法识别不同的语言
【发布时间】:2015-04-11 06:07:12
【问题描述】:

我现在从泰卢固语网站抓取数据,当我从网站获取英文内容时,我可以毫无问题地获取它,但假设内容是泰卢固语(印度的泰米尔语)

Site url

它没有返回正确的字符串。

Return string

代码:

<?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));

【问题讨论】:

  • 把你用来报废网页的代码放上去。

标签: php android mysql web-services web-scraping


【解决方案1】:

我已经在页面顶部设置了内容类型 utf-8 还设置了 phpmyadmin (Url) 中字段的集合“utf8_general_ci”现在浏览器检测语言(Url) 但是当这个 API 在 android 端调用时出现问题.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多