本帖最后由 codegay 于 2017-12-6 02:23 编辑
nim语言写的- import httpclient
- import re
- import os
-
- proc getlink*(url:string):string {.discardable.} =
- var client = newHttpClient()
- var link: array[1,string]
- var ddmaContent:string
- ddmaContent = client.getContent(url)
- client.close()
-
- if find(ddmaContent,re"""link1\"\s+href=\"(.+)\"""",link,1) != -1 :
- echo "link:",link[0]
- result = link[0]
- else:
- result = ""
-
- proc startlink*(url:string):int {.discardable.} =
- result = execShellCmd("start " & url)
-
- startlink(getlink("http://dd.ma/mE0NUHSi"))
复制代码
|