找回密码
 加入
搜索
查看: 8058|回复: 7

[求购] 淘宝要得到这个商品的,价格,名字。销量..

  [复制链接]
发表于 2012-7-19 18:12:17 | 显示全部楼层 |阅读模式
悬赏10金钱未解决
帮忙来个正则吧。淘宝要得到这个商品的,价格,名字。销量..
帮忙来个正则吧。淘宝要得到这个商品的,价格,名字。销量..
帮忙来个正则吧。淘宝要得到这个商品的,价格,名字。销量..

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.open("GET", "http://detail.tmall.com/item.htm?id=13620534478", False)
$oHTTP.send()
$source1 = $oHTTP.responsetext

Local $aTitle,$sTitle = ""
$aTitle = StringRegExp($source1,'name="title"\s*value="(.*?)"',3)
If Not @error Then $sTitle = $aTitle[0]

Local $aPrice,$iPrice = ""
$aPrice = StringRegExp($source1,'"J_StrPrice"\s*>(\d+\.\d+).*元',3)
If Not @error Then $iPrice = $aPrice[0]

Local $aSales,$iSales = ""
$aSales = StringRegExp($source1,'(?i)月\s销\s量:</SPAN><EM>(\d*)</EM>件',3)
If Not @error Then $iSales = $aSales[0]

MsgBox(0,"","商品名称:" & $sTitle & @CRLF & "价格:" & $iPrice & @CRLF & "月销量:" & $iSales)

发表于 2012-7-19 18:57:49 | 显示全部楼层
居然这么廉价,才10块论坛币。还是不看了
发表于 2012-7-20 08:41:07 | 显示全部楼层
本帖最后由 suiyefeng 于 2012-7-22 07:25 编辑
  
#include <WinHttp_GetRespond.au3>

$url = "http://detail.tmall.com/item.htm?id=13620534478"
$list = SellCount($url)

MsgBox(64,"月销量",$list)

Func SellCount($url)

        $rContext = _WinHTTP_GetRespond(-1, $url, 4 + 2, 10000)
        If @error Then
                Return -1
        EndIf
        ;获取含有销量的网址
        $initapi = StringRegExp($rContext[0], '"initApi" :.*"(.*?)"', 3)
        If Not IsArray($initapi) Then
                Return -2
        EndIf
        ;获取销量
        $rContext = _WinHTTP_GetRespond(-1, $initapi[0], 4 + 2, 10000)
        If @error Then
                Return -3
        EndIf

        $count = StringRegExp(BinaryToString($rContext[0]), '"sellCount":(\d*)', 3)
        If IsArray($count) Then
                Return $count[0]
        Else
                Return -4
        EndIf
        
EndFunc

评分

参与人数 1金钱 +10 收起 理由
dddxxx + 10 至少得鼓励下吧

查看全部评分

 楼主| 发表于 2012-7-20 21:16:10 | 显示全部楼层
回复 3# suiyefeng


    有时候得到销量=   -1. 不标准。。

我在摸索一下
发表于 2012-7-22 07:21:09 | 显示全部楼层
本帖最后由 suiyefeng 于 2012-7-22 07:33 编辑

汗      .....


改了点..你看返回的是的多少就知道问题出在哪了..剩下的你自己弄把
发表于 2012-8-27 15:59:52 | 显示全部楼层
淘宝开放平台,什么数据都能得到。
发表于 2012-12-7 15:57:50 | 显示全部楼层
代码我已经写好!
发表于 2012-12-7 15:59:37 | 显示全部楼层
#include <IE.au3>
#include<guiconstantsex.au3>
#include<file.au3>
#include<windowsconstants.au3>
GUICreate("IE", 500, 480)
Global $gccal = GUICtrlCreateInput("", 10, 340, 440, 30)
Global $gccal2 = GUICtrlCreateInput("", 10, 380, 440, 30)
Global $gccal3 = GUICtrlCreateInput("", 10, 420, 440, 30)
_IEErrorHandlerRegister()
$oie = _IECreateEmbedded()
Local $obj = GUICtrlCreateObj($oie, 10, 10, 490, 290)
GUISetState()
GUIRegisterMsg($WM_SYSCOMMAND, "wm_syscommand")
Global $url = "http://detail.tmall.com/item.htm?id=13620534478"
test($url)
While 1
        Local $msg = GUIGetMsg()
        Select
                Case $msg = -3
                        Exit
        EndSelect
        Sleep(1000)
WEnd

Func test($url)
        Local $html = _IENavigate($oie, $url)
        _IEAction($oie, "refresh")
        _IELoadWait($oie)
        Local $html3 = _IEBodyReadHTML($oie)
        $hw = FileOpen(@DesktopDir & "\1.txt", 10)
        FileWrite($hw, "")
        FileWriteLine(@DesktopDir & "\1.txt", $html3)
        Local $strarray
        _FileReadToArray(@DesktopDir & "\1.txt", $strarray)
        
        FileClose($hw)
        FileDelete(@DesktopDir & "\1.txt")
        GUICtrlSetData($gccal, "")
        For $i = 238 To $strarray[0]
                Local $strmid = StringRegExp($strarray[$i], "举报此商品", 3)
                If Not @error Then; 名称
                        Local $Strname = StringRegExp($strarray[$i - 1], 'target=_blank>([^\/]+?)</A>', 3) ;获取名称
                        If Not @error Then
                                GUICtrlSetData($gccal, "商品名称:" & $Strname[0])
                        EndIf
                EndIf
                Local $Sreg = StringRegExp($strarray[$i], 'Price>(\d+\.\d+)</STRONG>.*什么是专柜价', 3) ;获取价格
                If Not @error Then
                        GUICtrlSetData($gccal2, "价格:" & $Sreg[0] & " 元")
                EndIf
                Local $Srtmo = StringRegExp($strarray[$i], '.*月销量.+Num>(\d+)</EM>', 3) ;获取销量
                If Not @error Then
                        GUICtrlSetData($gccal3, "月销量:" & $Srtmo[0] & " 件")
                        ExitLoop
                EndIf
        Next

EndFunc   ;==>test

Func wm_syscommand($hWnd, $sMsg, $sWParam, $slParam)
        Switch $sWParam
                Case 61536
                        Exit
        EndSwitch
EndFunc   ;==>wm_syscommand
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-20 17:35 , Processed in 0.077159 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表