centos5.8 安裝CutyCapt CutyCapt 是Linux下抓取網頁截圖的軟件,須要先安裝QT,如下爲Centos 5.8 64 Bit 安裝 需求:有些網站長度過長,截圖太慢. 例如:163的網站,要抓取就須要屢次截圖,比較麻煩 原來想用命令curl抓取網頁內容,可是發現好多連接圖片是沒法抓取過來的. 1.增長atrpms的yum源 vi /etc/yum.repos.d/atrpms.repo [atrpms] baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/testing enabled=1 gpgcheck=0 2.安裝qt47及相應包(下面的這些安裝包,下載下來強制安裝吧,上面那個源裏面有兩個版本,容易形成版本衝突) qt47-4.7.2-1_18.el5 qt47-devel-4.7.2-1_18.el5 qt47-x11-4.7.2-1_18.el5 qt47-webkit-4.7.2-1_18.el5 qt47-webkit-devel-4.7.2-1_18.el5 phonon-backend-gstreamer-4.7.2-1_18.el5 rpm -Uvh --force --nodeps qt47-devel-4.7.2-1_18.el5.x86_64.rpm 3. 安裝 CutyCapt svn安裝 #yum install subversion svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt mv cutycapt/CutyCapt /usr/local/cutycapt cd /usr/local/cutycapt/ #這步網上不少都是直接用qmake,可是個人有問題,由於qmake是qt3的 qmake-qt47 make #* 再執行make的時候有可能會報以下錯誤 # make g++ -Wl,-O1 -o CutyCapt CutyCapt.o moc_CutyCapt.o -L/usr/lib64/qt47 -lQtWebKit -lQtSvg -L/usr/lib64/qt47 -lQtGui -lQtNetwork -lQtCore –lpthread /usr/lib64/qt47/libQtWebKit.so: undefined reference to `sqlite3_prepare16_v2' /usr/lib64/qt47/libQtWebKit.so: undefined reference to `sqlite3_column_value' collect2: ld returned 1 exit status make: *** [CutyCapt] Error 1 解決: 升級到sqlite-3.6,不要卸載在安裝 #若是是6.0,默認就是3.6 yum update sqlite #* make完就生成了CutyCapt這個可執行文件。 4. 運行環境 # ./CutyCapt --help CutyCapt: cannot connect to X server #* 網上不少都是要在裝個xvfb-run.sh的,其它不用這麼麻煩: echo "export DISPLAY=':1.0'" >> /etc/profile source /etc/profile vncserver [root@zhaoyong cutycapt]# ./CutyCapt --help --------------------------------------------------------------------- Usage: CutyCapt --url=http://www.example.org/ --out=localfile.png --------------------------------------------------------------------- --help Print this help page and exit --url=<url> The URL to capture (http:...|file:...|...) --out=<path> The target file (.png|pdf|ps|svg|jpeg|...) --out-format=<f> Like extension in --out, overrides heuristic --min-width=<int> Minimal width for the p_w_picpath (default: 800) --min-height=<int> Minimal height for the p_w_picpath (default: 600) --max-wait=<ms> Don't wait more than (default: 90000, inf: 0) --delay=<ms> After successful load, wait (default: 0) --user-style-path=<path> Location of user style sheet file, if any --user-style-string=<css> User style rules specified as text --header=<name>:<value> request header; repeatable; some can't be set --method=<get|post|put> Specifies the request method (default: get) --body-string=<string> Unencoded request body (default: none) --body-base64=<base64> Base64-encoded request body (default: none) --app-name=<name> appName used in User-Agent; default is none --app-version=<version> appVers used in User-Agent; default is none --user-agent=<string> Override the User-Agent header Qt would set --javascript=<on|off> JavaScript execution (default: on) --java=<on|off> Java execution (default: unknown) --plugins=<on|off> Plugin execution (default: unknown) --private-browsing=<on|off> Private browsing (default: unknown) --auto-load-p_w_picpaths=<on|off> Automatic p_w_picpath loading (default: on) --js-can-open-windows=<on|off> Script can open windows? (default: unknown) --js-can-access-clipboard=<on|off> Script clipboard privs (default: unknown) --print-backgrounds=<on|off> Backgrounds in PDF/PS output (default: off) --zoom-factor=<float> Page zoom factor (default: no zooming) --zoom-text-only=<on|off> Whether to zoom only the text (default: off) --http-proxy=<url> Address for HTTP proxy server (default: none) --------------------------------------------------------------------- <f> is svg,ps,pdf,itext,html,rtree,png,jpeg,mng,tiff,gif,bmp,ppm,xbm,xpm --------------------------------------------------------------------- http://cutycapt.sf.net - (c) 2003-2010 Bjoern Hoehrmann - bjoern@hoehrmann.de 安裝中文語言包 # yum install fonts-chinese 最後就能夠抓取想要的頁面了 [root@zhaoyong ~]# cd /usr/local/cutycapt/ [root@zhaoyong cutycapt]# ./CutyCapt --url=http://www.163.com/ --out=/root/163.jpg ---> 抓取的頁面的位置能夠隨意指定 轉換整個頁面至第一截屏 [root@zhaoyong ~]# convert -crop 1024x768+0+0 163.jpg 1632.jpg 縮小圖片 [root@zhaoyong ~]# convert -resize 40%x40% 1632.jpg 1632.jpg