请问怎么提取这个页面的汉字内容到数组?大侠帮帮忙啊

WBOY
Release: 2016-06-23 14:05:31
Original
929 people have browsed it

请问怎么提取这个页面的汉字内容到数组?谢谢
http://suggest.taobao.com/sug?extras=1&code=utf-8&callback=g_ks_suggest_callback&q=%E6%B5%8B%E8%AF%95


回复讨论(解决方案)

$s=file_get_contents('http://suggest.taobao.com/sug?extras=1&code=utf-8&callback=g_ks_suggest_callback&q=%E6%B5%8B%E8%AF%95');preg_match('/\{.+\}/',$s,$m);foreach(json_decode($m[0])->result as $v){     $arr[]=$v[0];}print_r($arr);
Copy after login

Array
(
    [0] => 测试男女
    [1] => 测试排卵期试纸
    [2] => 测试仪
    [3] => 测试纸 早孕
    [4] => 测试钞
    [5] => 测试皮肤水分笔
    [6] => 测试皮肤水分
    [7] => 测试甲醛试纸
    [8] => 测试纸
    [9] => 测试卡
)

你首先要用$s=file_get_contents('http://suggest.taobao.com/sug?extras=1&code=utf-8&callback=g_ks_suggest_callback&q=%E6%B5%8B%E8%AF%95'); 
这个获取得到他返回的数据
然后根据返回的数据特征,写正则获取

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template