kn007的个人博客
♥ You are here: Home > 软件与网络 > Autoit3 > 十一月末,冒泡

十一月末,冒泡

by | 30 Comments

提醒:本文最后更新于 2330 天前,文中所描述的信息可能已发生改变,请仔细核实。

100339h6ocsmoz9olfhs6t
11月最后一天,经过疯狂的加班,总算可以过过周末了,不过事情还是不少。

一直想写文章的,连文章都准备好了。但是内心突然没准备好发布。待以后再说吧。

明年1月15号,Google Code不再可上传文件到下载区了,原有下载文件仍然可以连接。新的文件,我也不想丢Google Drive里,所以势必转移所有文件。好在Google Code提供了Atom feeds,可以通过此来download所有在Google Code Download的文件,下面丢个autoit3脚本,可以下载所有文件(注意atom的显示数量)。不过我没加入容错,一般反正是没错的。请自行fix bug。

转移目标还没定。。不知道要放去哪里,要能外链还能不限流量,标准链接语法,稳定快速,全球可用,真难找。不知大家有什么推荐没有?

如果实在没有的话,考虑放本地。其他的没什么讲,看明天有时间就再扯扯。

话说,再送首歌吧!

;#AUTOITSCRIPT#=============================================================
; Name...........: Get Google Code Project’s Downloads
; Description ...: Download or list the project downloads flies.
;                       |The files from your google code project's downloads will be copied to the local folder from where the script is run.
; Author ........: kn007 <kn007 at 126 dot com>
; Parameters ....: $iFlag  -  Optional: specifies whether to list files to log or download files
;                       |$iFlag=0(Default) List files to LOG only
;                       |$iFlag=1 List and download these files
;==========================================================================Global
Const $FO_OVERWRITE = 2 ; Write mode (erase previous contents)
Global $Atom = 'https://code.google.com/feeds/p/kn007/downloads/basic'
Global $Parameter = '?max-results='
Global $MaxNum = '300'

Main(1)

Func Main($iFlag=0)
    Local $aSRE = List()
    ArrayWriteLOG('atom_list', $aSRE)
    If $iFlag = 0 Then Exit
    Local $i, $sName, $iSize = UBound($aSRE)
    For $i=0 To $iSize - 1
        $sName=StringRegExp($aSRE[$i], '/files/(.*)', 3)
        Local $hDownload = InetGet($aSRE[$i], @ScriptDir&'\'&$sName[0],1, 1)
        Do
            Sleep(1)
            TraySetToolTip('Downloading: '&$aSRE[$i])
        Until InetGetInfo($hDownload, 2)
        InetClose($hDownload)
    Next
    Exit
EndFunc

Func ArrayWriteLOG($sFilename, $aArray)
    Local $hFile = FileOpen(@ScriptDir & '\' &$sFilename & '.log', 1)
    _FileWriteFromArray($hFile, $aArray)
    FileClose($hFile)
EndFunc

Func List()
    Local $sPreGet = $Atom&$Parameter&$MaxNum
    Local $sResGet = Get($sPreGet)
    Local $sPTN = '<link rel="direct" href="(.*)" />'
    Return StringRegExp($sResGet, $sPTN, 3)
EndFunc

Func Get($oURL)
    Local $oHTTP = ObjCreate('winhttp.winhttprequest.5.1')
    $oHTTP.Open('get', $oURL, False)
    $oHTTP.Send()
    $sReturn = BinaryToString($oHTTP.responseBody)
    $oHTTP.Nothing
    Return $sReturn
EndFunc

;#FUNCTION#=================================================================
; Name...........: _FileWriteFromArray
; Description ...: Writes an array to a specified file.
; Author ........: Jos van der Zande <jdeb at autoitscript dot com>
; Modified.......: Updated for file handles by PsaltyDS, @error = 4 msg and 2-dimension capability added by Spiff59 and fixed by guinness.
;===========================================================================
Func _FileWriteFromArray($sFilePath, $aArray, $iBase = 0, $iUBound = 0, $sDelimeter = "|")
    ; Check if we have a valid array as input
    If Not IsArray($aArray) Then Return SetError(2, 0, 0)

    ; Check the number of dimensions
    Local $iDims = UBound($aArray, 0)
    If $iDims > 2 Then Return SetError(4, 0, 0)

    ; Determine last entry of the array
    Local $iLast = UBound($aArray) - 1
    If $iUBound < 1 Or $iUBound > $iLast Then $iUBound = $iLast
    If $iBase < 0 Or $iBase > $iLast Then $iBase = 0

    ; Open output file for overwrite by default, or use input file handle if passed
    Local $hFileOpen
    If IsString($sFilePath) Then
        $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE)
    Else
        $hFileOpen = $sFilePath
    EndIf
    If $hFileOpen = -1 Then Return SetError(1, 0, 0)

    ; Write array data to file
    Local $iError = 0
    Switch $iDims
        Case 1
            For $i = $iBase To $iUBound
                If FileWrite($hFileOpen, $aArray[$i] & @CRLF) = 0 Then
                    $iError = 3
                    ExitLoop
                EndIf
            Next
        Case 2
            Local $sTemp
            Local $iCols = UBound($aArray, 2)
            For $i = $iBase To $iUBound
                $sTemp = $aArray[$i][0]
                For $j = 1 To $iCols - 1
                    $sTemp &= $sDelimeter & $aArray[$i][$j]
                Next
                If FileWrite($hFileOpen, $sTemp & @CRLF) = 0 Then
                    $iError = 3
                    ExitLoop
                EndIf
            Next
    EndSwitch

    ; Close file only if specified by a string path
    If IsString($sFilePath) Then FileClose($hFileOpen)

    ; Return results
    If $iError Then Return SetError($iError, 0, 0)
    Return 1
EndFunc   ;==>_FileWriteFromArray

转载请注明转自:kn007的个人博客的《十一月末,冒泡

donate
有所帮助?

Comments

30 Comments立即评论
  1. au3?好复杂的代码~~米明天12月1号~来的真是时候~

    1. MOD回复

      @夜枫: 是au3。单纯想要下载的话,直接get->list->download就好了。不用这么复杂,我只是习惯了写成函数了,这样一环扣一环不易出错,出错好排除。

  2. LV4回复

    你去折腾googlecode,我把Ubuntu13.10中国麒麟定制版给装上了。。。。

    1. MOD回复

      @郑杰: :o 好吧。。我还是比较痛恨昨晚可以领50刀,你不告诉我。Ubuntu表示界面不错,不过没深入使用过。googlecode倒不难折腾,在搞别的东西

    2. LV4回复

      @kn007: ....你现在再去试试?说不定还能行

    3. MOD回复

      @郑杰: 把地址给我啊,QQ

  3. 不明觉厉了 :shock: :shock: :shock:

    1. MOD回复

      @喂蚊大帝: :lol: 谦虚了!

  4. autoit3,不明觉历,特意百度了下

    1. MOD回复

      @那时年少: :o 我前几篇文章都有写。。。说明你好久没来了

  5. 用git? :shock:

    1. MOD回复

      @be.truth: git。。。允许乱七八糟非主题文件上传么?

    2. @kn007: 我也只是胡说的 :shock:

    3. MOD回复

      @be.truth: :o :o :o 好吧。。。不过还是感谢

    4. @kn007: 其实你可以起一个杂物的主题嘛,多宏观的概念。 :mrgreen:

    5. MOD回复

      @be.truth: :???: 审批能过么。。

    6. @kn007: 如果真的会卡在审核的话,可以oschina的git托管。 ;-)

    7. MOD回复

      @be.truth: 还是算了,在国外无耻也就一回事。。在国内还这么无耻。。。不被喷死。。

  6. 12月初,我来冒个泡

    1. MOD回复

      @小怪物: 嘿嘿 :mrgreen:

  7. 其实我早来过,没留言。这次留言一下吧

    1. MOD回复

      @所谓刚子: :mrgreen: 我看到你的主题1.1,然后又不见了。奇怪,难道我幻觉。。

    2. @kn007: 一直没出过版本号啊。。。幻觉 哈哈

    3. MOD回复

      @所谓刚子: :lol: 我是在群里看到的额~不过点进去又不见了。。 :???:

  8. 加班快乐,12月啦,a new start

    1. MOD回复

      @hannah: 加班无爱

  9. 这歌曲不错

    1. MOD回复

      @灵尘子: 谢谢 :lol:

  10. LV4回复

    这函数,看着真心复杂

    1. MOD回复

      @Nemo: :o 写得太复杂,还是看得太复杂。。

icon_wink.gificon_neutral.gificon_mad.gificon_twisted.gificon_smile.gificon_eek.gificon_sad.gificon_rolleyes.gificon_razz.gificon_redface.gificon_surprised.gificon_mrgreen.gificon_lol.gificon_idea.gificon_biggrin.gificon_evil.gificon_cry.gificon_cool.gificon_arrow.gificon_confused.gificon_question.gificon_exclaim.gif