BT代抓

網路上看到介紹主要是這兩種:

Fetch.io免費帳號不提供BT代抓,付費帳號的空間跟頻寬如下(單位: USD/month)


4.95/m9.95/m19.95/m
Storage10G50G100G
Bandwith20G100G200


付費帳號的頻寬這個月沒用完可以累計到次月,算是好事,不過空間還是一樣大啊。
不曉得這個付費帳號抓的速度有沒有比torrific穩定?


Torrific目前在alpha測試階段,而在使用上比較麻煩的是:
  • 沒有上傳torrent檔案的選項,變成要找空間來放torrent檔案
  • 已經排入序列的torrent有時候會莫名其妙的被標示成"removed"
    要自己手動再把torrent加入序列中
  • 同時下載數目還是個謎啊? 有些torrent已經掛了兩三天了剩餘時間還是40小時?
    同一檔案用utorrent測試,是有seeder而且數量還不只一個,所以???????
  • 官網上對於使用上的限制沒有詳細說明,只好大家來玩猜一猜!!!

熱門檔案瞬間完檔真是最大的賣點啊,偏偏我找來測試檔案的好像都不熱門@@!

The Dark Side of NTFS

我真的很喜歡這種標題~XD~,扯遠了。

抓回來的一堆ACG檔案,有些額外的資料想要跟檔案『綁』在一起。
之前用XML檔案的方式,遇到改檔名就破功。所以,才想到要把資料塞到Filesystem裡面。

在NTFS裡面有兩種儲存metadata的方式:
  1. COM Structured Storage
  2. ADS(Alternate Data Streams)
下面有幾篇文章介紹ADS:
ADS commandline tools
上面是用notepad檢視ADS內容,更簡單的檢視方式是用:
more < filename:stream

目前看來ADS有趣的多(?)。ADS新增很容易,也很好修改,不過刪除有點麻煩。
'Create File
echo Hello World! > 1.txt

'Add data stream 
echo http://www.google.com.tw > 1.txt:URL

'Edit data stream
echo http://tw.yahoo.com > 1.txt:URL

'Delete data stream
more < 1.txt > 1.txt.new
del 1.txt
ren 1.txt.new 1.txt



10 Things to know about ADS
  1. There is no limit on the size of streams and there can be more than one stream linked to a normal file. ADS are not visible in explorer or via command prompt. In fact, their size is also not reported by Windows!
  2. Streams can be attached not only to files but also to folders and drives!
  3. The content of an ADS should not be considered limited to simply text data. Any stream of binary information can constitute a file which includes executables, Mpeg files, Jpeg files etc.
  4. ADS have no attributes of their own. The access rights assigned to the default unnamed stream are the rights that control any operation on ADSs such as creation, deletion or modification. This means if a user cannot write to a file, that user cannot add an ADS to that file. A user with guest privileges can also create such streams in every file where he has write access.
  5. Some Browser helper Objects (BHOs) have started storing their malicious files inside ADS and very few anti-spyware/malware actually detect it.
  6. Windows File Protection prevents the replacement of protected system files; it does not prevent a user with the appropriate permissions from adding ADS to those system files. The System File Checker (sfc.exe) will verify that protected
    system files have not been overwritten, but will not detect ADS.
  7. Microsoft Windows provides no tools or utilities either within the operating system software distribution or the Resource Kits for detecting the presence of ADS.
  8. The stream can only be executed if called directly by a program with the full path to the file given. It is impossible to accidentally execute a stream.
  9. None of the Internet protocols enabling file transfer such as SMTP, FTP etc. support streams. This means that ADS can't be sent via Internet. However, files containing ADS can be sent across a local LAN provided the target drive is in the NTFS format.
  10. In certain cases, streams have been used to remotely exploit a web server. Some web servers are susceptible to having their file source read via the: $DATA stream. If a server side script such as PHP or ASP is running on a web server which is not patched properly, instead of getting output as a result of processing the script, the source code of the ASP/PHP file could be viewed by using a URL like this:

    http://www.abcd.com/index.asp::$DATA

    This is a critical vulnerability as the server-side source code could reveal sensitive information including how the site has been coded and how the information is flowing. This information could be used by the attacker to launch a specific attack on the server. 

銷售量大增,但毛利率是多少? 營利率又是多少? 淨利率又是多少?

馬總統表示,政府協助漁民發展養殖、近海、遠洋漁業,希望永續發展,「以台灣為主,對漁民有利」。
他舉石斑魚為例,他上任前外銷量僅一百多公噸,金額兩千七百多萬元,去年則成長到廿四億元,成長達八十七倍。目前石斑魚養殖面積已超過兩千公頃,漁業署準備在兩年內將石斑魚產值翻倍,達到七十六億元,漁業絕對有很多發展機會。
重點是漁民賺到多少錢?

Reference:

[Python] 全角 → 半角

之前在抓Kattachi網站的漫畫資料的時候遇到個問題,他的文字大半都是全角文字。
對於之後的搜尋上面有點麻煩,本來想找全角→半角的module來處理。
不過,現在有內建的unicodedata可以處理這個問題。

print unicodedata.normalize("NFKC", u"iPod")

Reference:

[Python] Using mediainfo.dll to get file's metadata

程式碼參考了MediaInfo.DLL壓縮檔案內的MediaInfoDLL.py。
MediaInfoDLL.py已經把mediainfo.dll包好了,不過我只需要取得全部的資訊,class有太多東西都用不到,所以就自己寫了一個簡易版本的。

from ctypes import *

_mlib = windll.LoadLibrary("mediainfo.dll")

def getAllInform(filename):
    handle = c_void_p(_mlib.MediaInfo_New())
    _mlib.MediaInfo_Open(handle, c_wchar_p(filename))
    info = c_wchar_p(_mlib.MediaInfo_Inform(handle, c_size_t(0)))    
    return info.value

Reference:

Zotero Standalone

今天才看到有standalone版。稍微測試了一下:

  1. 消耗的記憶體不算少,空白資料庫要70MB+ (XULRunner 貢獻不少啊~)
  2. 速度比Firefox addon版快上不少
哪天才有stable release,Evernote免費版的限制不少。

Reference:

Everything SDK

在實驗Everything ETP的時候竟然發現,ETP Server當了= =|||。
好吧,我只是同時送了4個query過去,就當了>"<。找替代方案。

替代方案就是Everything SDK。
稍微測試一下,速度快很多。SDK是用IPC的方式跟Everything主程式溝通。所以Everything一定要開著,這點ETP也是一樣。

程式碼是參考(原创)在gvim中实现基于Everything SDK的极速搜索,稍作修改變成傳回list
from ctypes import *

def query(term):
    SE = windll.LoadLibrary("./SDK/everything.dll")

    strBuff=create_unicode_buffer(1024)
    SE.Everything_SetSearchW(c_wchar_p(term))

    try:
        SE.Everything_QueryW()
    except:
        SE.Everything_QueryW(0)

    results = []
    rcount = SE.Everything_GetNumResults()

    if rcount == 0:
        return results

    for x in range(0, rcount):
        SE.Everything_GetResultFullPathNameW(x, byref(strBuff), len(strBuff))
        results.append(strBuff.value)
    del strBuff, SE
    return results

Reference:

Baker - 簡化命令列選項的coding

以前要在script上增加命令列選項不外乎用optparse,或者是用新的argparse
Baker比上面那兩個更簡單。只需要:
  1. 在function的前面加一行@baker.command,該function就會成為command
  2. 在if __name__ == "__main__"區塊中加入baker.run()
Example:
import baker
# Add command
@baker.command
def foo():
    "foo is test command"


# Add parameter help
@baker.command(params={"force": "Delete even if the file exists"})
def delete(filename, force=False):
    "Delete a file."

@baker.command
def delete2(filename, force=False):
    """Deletes a file.
    :param force: Delete even if the file exists.
    """
    pass


# Short options
@baker.command(shortopts={"verbose": "v"}, params={"verbose": "Spew lots"})
def test(verbose=False):
    "test command"

#Run script
if __name__ == "__main__":
    baker.run()

Output:
python test.py 
Usage: X:\test.py COMMAND <options>

Available commands:

 delete   Delete a file.
 delete2  Deletes a file.
 foo      foo is test command
 test

Use "X:\test.py <command> --help" for individual command help.
python test2.py delete2 --help
Usage: X:\test.py delete2 <filename>

Deletes a file.

Options:

 --force  Delete even if the file exists.

(specifying a single hyphen (-) in the argument list means all
subsequent arguments are treated as bare arguments, not options)

Reference:

Search Everything via ETP

ETP簡單來說就是FTP+延伸指令。所以,外部程式若要利用ETP來搜尋檔案的話,需要基本的FTP支援。

  • 預設port: 5485
  • mode: PASV

Query syntax

QUERY <SP> <offset> <SP> <max> <SP> <match_case> <SP> <match_whole_word> <SP> <match_path> <SP> <search_string> <CRLF>
  • offset is the scroll bar offset (use 0 for all items)
  • max is the maximum number of visible items in the list. (use 0xffffffff for all items)
  • match_case can be non-zero for enabled, zero for disabled.
  • match_wholeword can be non-zero for enabled, zero for disabled.
  • match_path can be non-zero for enabled, zero for disabled.
  • search_string can be any number of parameters. 
Query reply
200 <SP> <offset> <SP> <count> <SP> <numfolders> <SP> <numfiles> <CRLF>
  • offset is the index offset of the first result.
  • count is the number of results that follow
  • numfolders is the total number of folders.
  • numfiles is the total number of files.
"count" results follow:
<full_path_name> <CRLF>
  • full path and file name of folder or file 

Python Example Code
def search(q, maxResult=1000, match_case=False, match_whole_word=False, match_path=True):
    # Query
    cmd = "QUERY 0 %d %d %d %d %s"%(maxResult, match_case, match_whole_word, match_path, q)

    # Query response offset control
    resp = ftp.sendcmd(cmd)
    code, offset, count, numfolders, numfiles = resp.split()

    results = []
    for i in range(int(count)):
        line = ftp.getmultiline().decode("UTF-8")
        results.append(line)

    return int(numfolders), int(numfiles), results


Reference:

Browser web scraping tools

BrowserAddonsNote
IEData Toolbar免費版有100筆資料上限
Google ChromeScraper

Yahoo Japan Web Search API

  1. 免費版有同時存取使用者上限,上限多少倒是沒提到。
  2. 免費版一個Application ID,24小時內不能超過1000個Request
  3. 這兩天測試的結果在台灣時間的晚上比較不容易遇到同時存取使用者上限的問題
Yahoo!検索Web APIについて、2011年3月31日(木)よりサービス内容を以下のように変更いたします。
【対象API】
(ウェブ検索API)
http://developer.yahoo.co.jp/webapi/search/websearch/v2/websearch.html
(画像検索API)
http://developer.yahoo.co.jp/webapi/search/imagesearch/v2/imagesearch.html


【変更内容】
1.同時にアクセス可能なユーザー数に制限を設けます(数セッションを上限とします)。超過した場合にはYahoo! JAPAN Web APIに共通のエラーメッセージおよびコードを返します。
2.24時間中、1つのアプリケーションIDにつき1,000件までのリクエストを上限とします。超過した場合にはYahoo! JAPAN Web APIに共通のエラーメッセージおよびコードを返します。

Reference:

orbitdm.exe (Orbit Downloader)

orbitdm.exe [/i/e/c] url:
  • /i - information
  • /e - HTTP Referer
  • /c - Cookie

Orbit downloader 讓我又愛又怕

優點:
  • 體積小
  • 速度快
  • 耗用記憶體少
缺點:

  • 更新若不注意常常會被改首頁
  • 更新若不注意會裝到不知道是什麼的軟體
  • Downloader怎麼管電腦裡安裝的程式= =?














它的優點符合我心目中理想工具程式的樣貌。不過缺點就讓人怕怕的,更新程式就要很小心不能Next一路點到底。有幾點覺得怪怪的:
  • 怎麼會去檢查電腦中安裝的程式? 
  • orbitdm.exe有命令列選項,不過官網卻說不支援命令列模式? 不希望被其他程式當成工具來使用嗎?

    [Mediawiki] full text search

    list=search (sr) *
      Perform a full text search
    
    This module requires read rights
    Parameters:
      srsearch       - Search for all page titles (or content) that has this value
                       This parameter is required
      srnamespace    - The namespace(s) to enumerate
                       Values (separate with '|'): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100, 101, 108, 109
                       Maximum number of values 50 (500 for bots)
                       Default: 0
      srwhat         - Search inside the text or titles
                       One value: title, text, nearmatch
      srinfo         - What metadata to return
                       Values (separate with '|'): totalhits, suggestion
                       Default: totalhits|suggestion
      srprop         - What properties to return
                        size             - Adds the size of the page in bytes
                        wordcount        - Adds the word count of the page
                        timestamp        - Adds the timestamp of when the page was last edited
                        score            - Adds the score (if any) from the search engine
                        snippet          - Adds a parsed snippet of the page
                        titlesnippet     - Adds a parsed snippet of the page title
                        redirectsnippet  - Adds a parsed snippet of the redirect
                        redirecttitle    - Adds a parsed snippet of the redirect title
                        sectionsnippet   - Adds a parsed snippet of the matching section
                        sectiontitle     - Adds a parsed snippet of the matching section title
                        hasrelated       - Indicates whether a related search is available
                       Values (separate with '|'): size, wordcount, timestamp, score, snippet, titlesnippet, redirecttitle, redirectsnippet, sectiontitle, sectionsnippet, hasrelated
                       Default: size|wordcount|timestamp|snippet
      srredirects    - Include redirect pages in the search
      sroffset       - Use this value to continue paging (return by query)
                       Default: 0
      srlimit        - How many total pages to return
                       No more than 50 (500 for bots) allowed
                       Default: 10
    Example:
    http://ja.wikipedia.org/w/api.php?action=query&list=search&srprop=score&srsearch=%E3%83%89%E3%83%A9%E3%82%B4%E3%83%B3%E3%83%9C%E3%83%BC%E3%83%AB%E6%94%B9%20%E4%BA%BA%E9%80%A0%E4%BA%BA%E9%96%93%20%E3%82%BB%E3%83%AB%E7%B7%A8%2014%20
    Reference:

    Google Web Search API return 403 ...

    在這篇Why does Google Search return HTTP Error 403? 有說明關於Error 403的原因。

    我就是因為這條吃了403 = =|||
    We received automated requests, such as scraping and prefetching. Automated requests are prohibited; all requests must be made as a result of an end-user action.

    API Key可以重新再登錄申請過就可以了,不過依照上面的限制,Web Search API的實用性就大打折扣了。原因不難理解,畢竟Google是靠廣告吃飯的。

    要用Web Search API做Data mining難了...
    Usually not a problem if you are just providing web users with a search box, but not helpful if you're trying to use Google to go data mining. I guess they don't want you to go data mining using their API.

    另外,要模擬瀏覽器送出搜尋的話只需要在HTTP Request中增加"User-Agent"欄位,把Firefox的user-agent填上去就可以了。不過這種做法,速度沒有Web Search API快。

    Reference:

    Gethcu & Google Reader





    基本上是從Getchu.com抓Game/Anime資料再丟給Google Reader去找出相關的文章。
    接著再把相關條目丟給Google Web Search API搜尋:
    • Wikipeida的相關的條目網址(以en, jp, zh三種語言為主)
    • Moeimouto的相關的tag URL
    Wikipedia跟Moeimouto都有內建搜尋,不過Getchu抓出的資料當中有蠻多無用的詞彙在其中。所以,搜尋的結果不太好,當然無用的詞彙可以自己過濾,不過要花時間去建立對應表,倒不如直接用Google Web Search去充當過濾器比較快。

    另外,我也想過是否要把某些Game/Anime的標題用Google Translate/J-Talk.com將之翻譯成英文或羅馬拼音,近一兩年的Anime/Game都可以用日文標題直接找,某些年代久遠的未必能用日文標題搜尋就可以找出滿意的結果。


    怎麼不全用Google Web Search API做?

    1. Web Search API沒有全文輸出,要找內容還是需要自己去抓網頁資料。
    2. 我的Reader大約有300左右的訂閱,只需要2個HTTP Request就可以搜尋約300個左右的訂閱,是比Web Search來的快。
    3. Reader可以指定傳回搜尋結果的數量。預設是20個。相較之下Web Search是8個,要取得20個搜尋結果, Web Search需要做3次HTTP Request。
    4. Web Search API有查詢限額
    Anime/Game這部分用Google Reader取得的搜尋結果比我測試Manga的結果好多了,上面右邊的圖是搜尋300訂閱的結果,我想如果把Anime/Game相關的訂閱都放在一個folder之下,結果應該會蠻不錯的。但這也很難完全避免SEO所帶來的雜訊。

    Google Web Search API

    在2013/11/1前都還可以用啊,不過還是希望Custom Search API的額度可以拉高一點。

    Note: The Google Web Search API has been officially deprecated as of November 1, 2010. It will continue to work as per our deprecation policy, but the number of requests you may make per day will be limited. Therefore, we encourage you to move to the new Custom Search API.

    Reference:

    Google Reader & Custom Search

    網路上可以找到如何將Google Reader的訂閱匯出成OPML,再導入Custom Search
    建立搜尋。看完後本想用Custom Search API來取代自己寫的Google Reader Client,
    問題是看到下面時就放棄了。Custom Search API一天的限額只有100 queries/day.......
    還是乖乖用自己寫的code吧。

    計費方式:
    However, you will be billed for all additional requests at the rate of 
    $5 per 1000 queries, for up to 10,000 queries per day.


    [Mediawiki API] 取得其他不同語言的網址

    http://en.wikipedia.org/w/api.php?action=query&prop=langlinks&redirects=&format=json&llurl=&lllimit=100&titles={titles}
    • title, 文章標題要用application/x-www-form-urlencoded編碼
    • format=josn|jsonfm|xml|xmlfm(傳回格式,其中...fm代表pretty-print
    • llimit=100(傳回語言連結的數量,最多500)
    • llurl= (傳回語言連結的完整網址)
    Test:

    Google Reader API for Search

    Get SID

    POST https://www.google.com/accounts/ClientLoginResponse
    FORM:
    • service=reader
    • Email={loginEmail}
    • Passwd={loginPassowrd}
    HTTP Resonse:
    • SID=…\n
    • LSID=…\n
    • Auth=…\n

    Get Token for later operations

    GET http://www.google.com/reader/api/0/token
        Add Extra HTTP Header for getting Token and other operations
            1. Cookie: SID={SID from ClientLogin}
            2. Authorization: GoogleLogin auth={Auth from ClientLogin}  

    All {keyword} are encoded in UTF-8 with application/x-www-form-urlencoded format

    Search Reader with <keyword>

    # Get search result item index
    GET  http://www.google.com/reader/api/0/search/items/ids?q={keyword}&num=1000&output=json&ck={timestamp}&client=scroll

    HTTP Response:
    JSON ["results"] -> [{"id":item index}, {"id":item index}, .....]

    # Get search result item content
    POST http://www.google.com /reader/api/0/stream/items/contents?ck={timestamp}&client=scroll
    POST FORM:
    • i=item index
    • it=0
    • T=Token 

    Search Reader with <keywords> <Feed>

    GET /reader/api/0/search/items/ids?q={keyword}&num=1000&s=feed/{feed url}&output=json&ck={timestamp}&client=scroll

    POST /reader/api/0/stream/items/contents?ck={timestamp}&client=scroll


    Search Reader with <keywords> <folder>

    GET http://www.google.com/reader/api/0/search/items/ids?q={keyword}&num=1000&s={folder}&output=json&ck={timestamp}&client=scroll

    POST http://www.google.com /reader/api/0/stream/items/contents?ck={timestamp}&client=scroll


    Feed listing

    GET http://www.google.com/reader/api/0/stream/contents/feed/{feed url}?

    • ot=[unix timestamp] : The time from which you want to retrieve items. Only items that have been crawled by Google Reader after this time will be returned.
    • r=[d|n|o] : Sort order of item results. d or n gives items in descending date order, o in ascending order.
    • xt=[exclude target] : Used to exclude certain items from the feed. For example, using xt=user/-/state/com.google/read will exclude items that the current user has marked as read, or xt=feed/[feedurl] will exclude items from a particular feed (obviously not useful in this request, but xt appears in other listing requests).
    • n=[integer] : The maximum number of results to return.
    • ck=[unix timestamp] : Use the current Unix time here, helps Google with caching.
    • client=[your client] : You can use the default Google client (scroll), but it doesn't seem to make a difference. Google probably uses this field to gather data on who is accessing the API, so I'd advise using your own unique string to identify your software.

    Reference:

    蚊子館與塌塌橋

    難怪有網友在塌陷事故發生後,提議拆了趙州橋——這座坐落在河北省趙縣洨河上、建於隋代大業年間的橋太“招惹是非”了,匠師李春建造後愣是1400餘年不倒,這讓那些塌了再修、修了再塌的路橋情何以堪?一座豆腐渣工程,對GDP的貢獻其實是很大的:修建的時候拉動經濟,回頭天天打補丁,還是拉動就業、提升總量,就算真倒了,哪怕人命關天,也是再建新功的好契機。至於問責呢?誰也別較真,自有痴狂的專家準時跳出來“和稀泥”。這就是公共基建問題不斷、卻又病 程不決的根源。

    與台灣的蚊子館、蚊子工業區異曲同工啊。
    那路平專案呢?

    資料來源:
    錢塘三橋,垮塌的偶然與必然

    SiteShoter 補遺

    如果要每五分鐘對該網站做一次screenshot,
    用Siteshoter /RunConfig "cfgFile" 只做一次screenshot,之後程式就結束了。

    解決方法是:
    siteshoter /LoadConfig "cfgFile" /Start
    這樣就會每隔一段時間做一次screenshot,直到使用者關閉程式為止。

    或者是用命令列下的taskkill
    taskkill /F /IM siteshoter.exe 

    客戶的遊艇在哪裡?

    吳敦義劉憶如 拜託銀行幫幫忙
    行政院長吳敦義和經建會主委劉憶如今天向銀行喊話,「拜託銀行幫幫忙!」一方面希望銀行以服務財富管理客戶的精神,和管理客戶資產的專業,把政府當成財管客戶,集思廣益、提供意見,讓財務艱困的政府,財政健全、走上健康的道路。
    另一方面,也希望銀行協助改善國內的貧富差距問題,劉憶如並建議,銀行承作的財富管理,可透過手續費收入打折等誘因,多開發年收入在110萬元、120萬元左右的基層客戶,讓這些族群的小錢變大錢,而不要只是服務有錢人。
    【2011/07/13 聯合報】@ http://udn.com/

    看完上面的新聞,讓我想到一個故事:
    有一本經典的書叫《顧客的遊艇在哪裡?》(Where Are the Customers' Yachts?),一位住在美國中西部的農人,退休之後到各地去遊覽,有一次參加到紐約觀光的旅行團,由於紐約的華爾街是全世界的金融重鎮,當然也在行程之列,農人對於華爾街能夠有如此繁榮的景象驚異不已,心想這裡一定創造出不少大富翁。果不其然,接著導遊領著他們到紐約長島(Long Island)的碼頭,一一為他們介紹,這是某某銀行家的豪華遊艇,那是某某名股票經紀人的私人遊艇,令農人欽羡不已,但是他突然納悶的問了一句:「那客戶的遊艇停在那裡呢?」。

    資料來源:
    聯合新聞網: 吳敦義劉憶如 拜託銀行幫幫忙
    投資基本法: 股市預測 (十二) 基本分析-騙人的投資專家(經紀佬)

    My Weekly Browsing Schedule

    iMacros免費版不支援Windows 工作排程,所以只好用Firefox addons的方式來達成
    下面有詳細的介紹
    3 Best FireFox Addons That Will Help You To Organize and Schedule Daily Browsing

    之前用Do it again,有點小問題,如果拉動了sidebar的寬度,位置會跑,變成做白工。

    iMacros是我用來抓網頁資料的工具,免費版缺Flash與Windows工作排程所以變通的方式是:

    SiteShoter

    Siteshoter 將要抓取的網址設定完畢之後從成*.cfg檔案
    可用:
    siteshoter /RunConfig "設定檔案完整路徑" 來執行(不會出現任何視窗)

    siteshoter在檔名可用的變數,詳細說明可參照http://www.nirsoft.net/utils/web_site_screenshot.html

    • %url%
    • %host%
    • %name%
    • %date:[format]%
    • %time:[format]%
    最後,siteshoter的命令列選項,會蓋過cfg檔案中的設定,比較常用的是

    參數說明
    /URL指定網址
    /FILENAME指定存檔檔名
    /RunConfig "config file path"讀取設定檔並執行
    /LoadConfig "config file path"讀取設定檔
    /Start配合/LoadConfig來執行Take screenshot every .... minutes的動作

    iMacro 常用指令與變數

    URL GOTO=url
    開啟指定的網址,但開啟某些網頁時會出現-933的error code,可以用SET !ERRORIGNORE YES 忽略。這部分很怪,明明瀏覽器出現了網頁的內容,卻有-933的error code, 而error code -933代表的是Network error while file or page loading這該不會是bug?!

    WAIT SECONDS=n, 等待n秒,某些網站Ajax個技術更新內容的時候就會用到

    SET 設定內建變數,這部分免費版的iMarco只有內建變數跟!VAR1, !VAR2, !VAR3這幾個變數可以用。免費版無法自訂變數。
     變數取值{{!變數名稱}},例如:取得!VAR1的資料→{{!VAR1}}

    內建的時間變數取值{{!NOW:yyyymmdd_hhnnss}} 
    + yyyy - 西元年
    + mm - 月
    + dd - 日
    + hh - 小時
    + nn - 分(這跟習慣的time format有點不太一樣)
    + ss - 秒

    '註解

    SAVEAS TYPE=(CPL|MHT|HTM|TXT|EXTRACT|JPEG|PNG) FOLDER=folder_name FILE=file_name  

    TYPE:
    • CPL - 完整網頁
    • MHT - 封存網頁檔
    • HTM - 只有HTML
    • TXT - 只有文字,HTML標籤會被忽略
    • EXTRACT 要配合TAG ... EXTRACT=TXT|TXTALL|HTM ...
    • JPEG - 將網頁存成圖檔(免費版不支援Flash,所以Flash的部分會是空白)
    • PNG - (同TYPE=JPEG)
    FOLDER:
    • FOLDER=*(將檔案下載到C:\Documents and Settings\{username}\My Documents\iMacros\Downloads)
    • FOLDER=C:\Download(將檔案存到C:\Download)
    FILE:
    • FILE=* (使用預設檔名extract.csv)
    • FILE=test1 (設定檔名為test1,副檔名可以忽略,iMacros會自動把TYPE=..當成副檔名補上)
    • FILE=+{{!NOW:yyyymmdd}} (檔名:網頁標題+yyyymmdd)
    注意事項:
    • FOLDER與FILE中若有空白字元,要用<SP>來替代空白字元。
    • 若TYPE=TXT,檔案已經存在的話,會將內容附加到檔案尾端。若是TYPE=JPEG|PNG的話,會覆蓋檔案內容。

    ONDOWNLOAD FOLDER=folder_name FILE=file_name  
    FOLDER:
    • FOLDER→設定方法與SAVEAS相同
    • FILE→設定方法與SAVEAS相同

    TAG POS=n TYPE=type [FORM=form] ATTR=attr [CONTENT=some_content]  
    • POS=n 某個標籤的絕對位置(在HTML檔案中的順序)
    • TYPE=標籤名
    • FORM=表單名稱
    • ATTR=標籤屬性
    • CONTENT=配合FORM填入特定值,或是觸發特定事件如EVENT:SAVEITEM

    TAG指令的參數自己填很麻煩,所以通常是用錄製的方式去點選網頁元素,讓iMarcos自動填上相關TAG指令的參數。

    錄製模式中的Click Mode通常選擇第一個就可以了














    ONDOWNLOAD與TAG這兩個指令常配合一起使用,用來抓取網頁中特定的項目,如指定的圖片或文字。

    例如: 從玩股網抓騰落線圖,並將檔案存到C:\ADLines, 檔名為ADLine_yyyymmdd.png

    URL GOTO=http://www.wantgoo.com/hottip.aspx?m=adline
    ONDOWNLOAD FOLDER=C:\ADLines FILE=ADLine_{{!NOW:yyyymmdd}}.png
    TAG POS=1 TYPE=IMG ATTR=ID:ctl00_service_ADline1_imgADline CONTENT=EVENT:SAVEITEM
    上面藍字的部分是用iMacros錄製完畢之後,自己再加上去的。

    例如: 從StockQ抓取經濟數據
    URL GOTO=http://www.stockq.org/economy/
    TAG POS=7 TYPE=TABLE ATTR=TXT:* EXTRACT=TXT
    SAVEAS TYPE=EXTRACT FOLDER=C:\ FILE=StockQ.csv
    上面藍字的部分是用iMacros錄製完畢之後,自己再加上去的。

    用ONDOWNLOAD設定TAG CONTENT=
    • EVENT:SAVEITEM
    • EVENT:SAVE_ELEMENT_SCREENSHOT
    的存檔的目錄與檔名。

    TAG CONTENT參數只能用在:
    • 填表單資料
    • 觸發事件,如: CONTENT=EVENT:SAVEITEM
    • TAG CONTENT=EVENT:SAVEITEM不能與EXTRACT一起使用

    另外,TAG比較麻煩的地方是抓HTML TABLE的部分,有時候需要自己開網頁原始碼來算一下,要的資料是在第幾個TABLE 。

    有用到EXTRACT參數的話記得要把SET !EXTRACT_TEST_POPUP NO,要不然會跳出視窗,腳本會停在TAG EXTRACT=...那一行。

    EXTRACT=TXT|TXTALL|HTM|HREF|TITLE
    • TXT 標籤所包圍的文字內容
    • TXTALL 下拉式選單的內容
    • HTM HTML
    • HREF 抓取<A>的HREF屬性
    • TITLE 抓取<A>...</A>所包圍的文字
    詳細範例可參照:http://wiki.imacros.net/Data_Extraction

    關於TAG參數EXTRACT與SAVEAS指令:
    • If several EXTRACT commands appear in one macro the results are separated by the string [EXTRACT]. This string is automatically translated into a line break when using the "SAVEAS TYPE=EXTRACT" command. 
    • If complete tables were extracted then adjacent table elements are separated by the string #NEXT# and ends of table rows are delimited by the string #NEWLINE#. These tags are automatically translated into commas and newlines when you use the "SAVEAS TYPE=EXTRACT" command. 
    
    
    TAB (T=n|OPEN|CLOSE|CLOSEALLOTHERS)
    • T=n, 指定第n個分頁作為目前分業
    • T=OPEN, 在背景開啟新分頁
    • T=CLOSE, 關閉目前分頁
    • T=CLOSEALLOTHERS, 關閉目前分頁外的所有其他分頁


    免費版很多功能都沒有或是不完整,詳細可參考:http://iopus.com/imacros/compare/all/
    目前免費版最好用的功能是: 抓取網頁文字或是將網頁存成圖片(網頁中若有Flash就要找其他方案了)

    Reference: