kxing 发表于 2010-11-4 08:47:44

[已解决]新浪新闻的采集问题

本帖最后由 kxing 于 2010-11-4 13:36 编辑

我希望通过inetget下载援文件用正则提取新闻条目。
但是,这个叶面的新闻用了一个js循环完成的。
下载回来的htm文件并没有实际新闻内容。
请高手帮忙解决,多谢!!!

http://news.sina.com.cn/hotnews/

蜘蛛抱蛋 发表于 2010-11-4 10:15:17

我看了下,他的数据是通过PHP获得然后本地解析的
获取数据的url在JS里有诸如http://top.news.sina.com.cn/ws/GetTopDataList.php?top_type=day&top_cat=china&top_time=20101104&top_show_num=20&top_order=ASC&js_var=all_1_data获取的标题是Unicode编码   自己转码一下就可

3mile 发表于 2010-11-4 11:40:00

初步做了一下,楼主自行扩展吧。
#include <array.au3>
#include <string.au3>
#include <INet.au3>

$s_URL='http://top.news.sina.com.cn/ws/GetTopDataList.php?top_type=day&top_cat=www_all&top_time=20101104&top_show_num=100&top_order=ASC&js_var=all_1_data'
$soure=_INetGetSource ( $s_URL )
FileWrite('url.txt',$soure)
;$soure=FileRead('soure.txt')
$s_array=StringRegExp($soure,'{(.*?)}',3)
Local $temp_str,$temp,$temp_s,$string
Local $array
For $i=1 To UBound($s_array)-1   
    $temp_str=''
    $array[$i]=$s_array[$i]
    $temp=StringRegExp($s_array[$i],'"(.*?)"',3)
    $array[$i]=hextostring($temp)
    $array[$i]=hextostring($temp)
    $array[$i]=url($temp)
    $array[$i]=url($temp)
Next
_ArrayDisplay($array)

Func Hextostring($string)
    Local $temp_str,$temp_s
    $temp_s=StringSplit($string,'\u',3)
    $string=''
    For $n=1 To UBound($temp_s)-1
      If StringLen($temp_s[$n])<>4 Then
            $temp_s[$n]=ChrW('0x'&StringMid($temp_s[$n],1,4))&StringMid($temp_s[$n],5)
            $string&=$temp_s[$n]            
      Else
      $temp_s[$n]=ChrW('0x'&$temp_s[$n])
      $string&=$temp_s[$n]
      EndIf
    Next
    Return $string
EndFunc

Func url(ByRef $string)
    Local $url
    $string=StringReplace($string,'\/','/')
    Return $string
EndFunc
   
   

kxing 发表于 2010-11-4 13:33:10

万分感激!!!!

Netfox 发表于 2011-1-14 00:25:52

{:face (332):}

Netfox 发表于 2011-1-14 00:26:11

呵呵,还是牛人多啊

京东论坛 发表于 2011-11-25 09:03:38

初步做了一下,楼主自行扩展吧。
3mile 发表于 2010-11-4 11:40 http://www.autoitx.com/images/common/back.gif


    牛人啊!!!!!

hfwcy 发表于 2011-12-30 14:49:02

{:face (382):}

ollydbg 发表于 2014-8-14 21:14:41

3mile 牛人啊
页: [1]
查看完整版本: [已解决]新浪新闻的采集问题