鯤鵬數據開源庫python_google_translator介紹

 原文做者:西安鯤之鵬html

原文連接:http://www.site-digger.com/html/articles/20130812/68.htmlpython

關於KPBroswer:算法

KPBroswer是一個基於QtWebKit的最小化瀏覽器程序,經過被第三方程序調用,
能實現對複雜頁面加載後數據(例如,複雜Ajax、數據加密)的抓取,支持屏幕截圖。
KP是「鯤鵬」二字的拼音首字母。
 
項目主頁:
 
 
適用場景:
頁面數據動態加載(例如,Ajax過程過於複雜,分析成本過高);
數據加密(客戶端JS解密,解密算法難以獲取或難以用其它語言實現);
屏幕截圖;
 跨平臺的抓取方案;
 
依賴庫:
PyQt4 
Ubuntu下安裝方法:sudo apt-get install python-qt4
Windows下安裝方法:在這裏下載二進制安裝包直接安裝http://www.riverbankcomputing.co.uk/software/pyqt/download/
 
調用方法:
若在Linux終端下運行,須要安裝Xvfb。Ubuntu下安裝方法:apt-get install xvfb xfonts-base xfonts-75dpi xfonts-100dpi xfonts-wqy
調用舉例(Linux):xvfb-run python KPBroswer.py http://www.site-digger.com --flags=redice --output="page.html" --screenshot="sitedigger.jpg"
調用舉例(Windows):python KPBroswer.py http://www.site-digger.com --flags=redice --output="page.html" --screenshot="sitedigger.jpg"
 
Usage: KPBroswer.py <URL> [options]
 
Options:
  -h, --help            show this help message and exit
  -p PROXY, --proxy=PROXY
                        Proxy to use.
  -t TIMEOUT, --timeout=TIMEOUT
                        The timeout time of loading page.
  -f FLAGS, --flags=FLAGS
                        Flags need to wait for. Semicolon can be used as a
                        eperator.
  -w WAIT_TIMEOUT, --wait_timeout=WAIT_TIMEOUT
                        The timeout time of waitting for flags.
  -g, --gui             Whether to show the broswer GUI.
  -o OUTPUT, --output=OUTPUT
                        The output filename.
  -s SCREENSHOT, --screenshot=SCREENSHOT
                        If the value is not empty, take a screenshot and save
                        it here.
 
注意:
Linux下不要忘記安裝相關字體庫,不然截圖中的漢字將會是亂碼,以下圖site-digger-font-problem.jpg所示。
安裝後,就正常了,如圖site-digger.jpg所示。
 
示例:
sample.py文件爲一個Python之外部程序方式調用KPBroswer.py的示例,其它語言的調用能夠參考其實現。
特別說明:該文章爲西安鯤之鵬的原創文章 ,你除了能夠發表評論外,還能夠轉載到你的網站或博客,可是請保留源地址,謝謝!!(尊重他人勞動,你我共同努力)
相關文章
相關標籤/搜索