Linux webpage screenshot-shell

Source: Internet
Author: User
Linux web page-shell Summary: The boss temporarily arranges tasks and regularly archives and stores a large number of websites (in. The earliest solution in window was webshot0000.exe + batch processing. Run the timer time and find that the webshotcmd.exe process is often popped up... linux webpage-shell summary: the boss needs to schedule tasks on a temporary basis and regularly archive and save a large number of websites (in ten thousand units. The earliest solution in window was webshot0000.exe + batch processing. After running the timer time, it is found that the window that does not respond to the webshot.exe program often pops up. you need to manually click OK to continue. Moreover, the figure captured by the unregistered webshocmd version is gray, which is inconvenient for viewing. Google detected the two linux tools cutycapt and phantomjs. after testing, the cutycapt was slow but stable. phantomjs was fast, but sometimes the process was suspended. Weigh the pros and cons and decide to use the cutycapt + shell script to temporarily schedule tasks for the boss. it is necessary to regularly archive and save a large number of (10 thousand) websites. The earliest solution in window was webshot0000.exe + batch processing. After running the timer time, it is found that the window that does not respond to the webshot.exe program often pops up. you need to manually click OK to continue. Moreover, the figure captured by the unregistered webshocmd version is gray, which is inconvenient for viewing. Google detected the two linux tools cutycapt and phantomjs. after testing, the cutycapt was slow but stable. phantomjs was fast, but sometimes the process was suspended. Weigh the pros and cons and decide how to use the cutycapt + shell script: webshot. sh 01 #/bin/bash02 # webhsot03 # by caishzh 201304 05 WEBSHOTDIR = "/data/webshot" 06 mkdir-p $ WEBSHOTDIR07 08 while read LINE09do10 DISPLAY =: 0 cutycapt -- url = http: // $ LINE -- max-wait = 90000 -- out = $ WEBSHOTDIR/linline.jpg>/dev/null 2> & 111 done /Dev/null 2> & 116 done17} & 18done19wait20 # Delete the temporary file 21rm x *-f generated by spilt. Note: Use splitto split domain.txt into multiple files first, each file contains 5000 rows, and two nested for loops are used to implement multiple processes. The first for is to list the file names separated by split, and the second for the websites in these files. pay attention to &, & the role is to put the script code in braces in the background for execution, which simulates the effect of processing "Multithreading". In reality, it is a multi-process. Wait is executed only after all the preceding background tasks are completed. Using this script greatly improves the speed and completes all websites in about two days, with remarkable results. It should be noted that cutycapt requires a large amount of network bandwidth and cpu resources. do not open too many cutycapt "Threads" on machines with poor configuration to Avoid machine crashes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.