Advertisement
hackloper775

marcadores_to_pdf

Aug 7th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.30 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. which zenity >> /dev/null
  4. if [ ! $? = 0 ]; then
  5.    echo "Falta zenity"
  6.    exit
  7. fi
  8.  
  9. which wkhtmltopdf >> /dev/null
  10. if [ ! $? = 0 ]; then
  11.    echo "Falta wkhtmltopdf"
  12.    exit
  13. fi
  14.  
  15.  
  16. function create_dir_pdf()
  17. {
  18.     if [ -d "pdfs_chromer" ]
  19.     then
  20.         echo -n ""
  21.     else
  22.         mkdir "pdfs_chromer"
  23.     fi
  24.     cd "pdfs_chromer"
  25. }
  26.  
  27. create_dir_pdf
  28.  
  29. MARCADORES=`zenity --file-selection --file-filter='*.html' --title="Selecciona tu html"`
  30.  
  31. if [ $? -eq 1 ];
  32. then
  33.     exit
  34. fi
  35. o=0
  36.  
  37. declare -a {pages,nombres,}
  38.  
  39. cat $MARCADORES | grep 'http.*"' | sed 's/http.*"//g;s/.*=">//g;s/[<].*//g' > pages_chrome.txt
  40.  
  41. for i in `cat $MARCADORES | grep 'http.*"' | sed 's/ADD.*//g; s/.*HREF=//g; s/"//g'`
  42. do
  43.     pages[$o]=$i
  44.     let o=o+1
  45.  
  46. done
  47. o=0
  48. while read linea
  49. do
  50.     nombres[$o]=$linea
  51.     let o=o+1
  52. done < pages_chrome.txt
  53.  
  54. i=0
  55.  
  56. while [ $i -lt ${#pages[*]} ]
  57. do
  58.     echo "Procesando : ${nombres[$i]} $i/${#pages[*]}"
  59.     wkhtmltopdf ${pages[$i]} "${nombres[$i]}"
  60.     let i=i+1
  61. done
  62.  
  63. rm pages_chrome.txt
  64.  
  65.  
  66. #This library is free software; you can redistribute it and/or modify it under
  67. #the terms of the GNU Library General Public License as published by the Free
  68. #Software Foundation; either version 2.1 of the License, or (at your option) any
  69. #later version.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement