Paulo87

Extrator de cloud

Jun 30th, 2024
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Extrator de Dados</title>
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <style>
  7. body {
  8. background-color: #121212;
  9. color: #eee;
  10. font-family: 'Courier New', Courier, monospace;
  11. margin: 0;
  12. padding: 20px;
  13. }
  14. h2 {
  15. color: #8a2be2;
  16. text-align: center;
  17. font-size: 1.8em;
  18. margin-bottom: 20px;
  19. }
  20. label {
  21. display: block;
  22. margin-bottom: 5px;
  23. color: #d4d4d4;
  24. font-size: 1em;
  25. }
  26. input[type="text"], input[type="file"] {
  27. background-color: #252525;
  28. color: #eee;
  29. border: 2px solid #8a2be2;
  30. padding: 10px;
  31. margin-bottom: 15px;
  32. width: calc(100% - 24px);
  33. transition: border-color 0.3s;
  34. font-size: 1em;
  35. }
  36. input[type="text"]:focus, input[type="file"]:focus {
  37. outline: none;
  38. border-color: #c084ff;
  39. }
  40. button {
  41. background-color: #8a2be2;
  42. color: #eee;
  43. border: none;
  44. padding: 10px 20px;
  45. font-weight: bold;
  46. cursor: pointer;
  47. transition: background-color 0.3s;
  48. font-size: 1em;
  49. width: 100%;
  50. }
  51. button:hover {
  52. background-color: #c084ff;
  53. }
  54. #output {
  55. margin-top: 20px;
  56. border: 1px solid #8a2be2;
  57. padding: 10px;
  58. background-color: #1e1e1e;
  59. color: #d4d4d4;
  60. white-space: pre-wrap;
  61. font-size: 0.9em;
  62. }
  63. #progressBar {
  64. width: 0%;
  65. height: 10px;
  66. background-color: #8a2be2;
  67. margin-top: 10px;
  68. border-radius: 5px;
  69. }
  70. </style>
  71. </head>
  72. <body>
  73.  
  74. <h2>Extrator de Dados</h2>
  75. <label for="keyword">Palavra-chave:</label>
  76. <input type="text" id="keyword" name="keyword">
  77. <input type="file" id="fileInput">
  78. <button onclick="extractLinks()">Extrair Dados</button>
  79. <div id="progressBar"></div>
  80. <div id="output"></div>
  81.  
  82. <script>
  83. function extractLinks() {
  84. const fileInput = document.getElementById('fileInput');
  85. const keyword = document.getElementById('keyword').value;
  86. const output = document.getElementById('output');
  87. const progressBar = document.getElementById('progressBar');
  88. output.innerHTML = '';
  89. progressBar.style.width = '0%';
  90.  
  91. if (fileInput.files.length > 0) {
  92. const file = fileInput.files[0];
  93. const reader = new FileReader();
  94. const chunkSize = 1024 * 1024 * 50;
  95. const extractedData = [];
  96. let offset = 0;
  97.  
  98. reader.onload = function(e) {
  99. const chunk = e.target.result;
  100. const lines = chunk.split('\n');
  101.  
  102. for (const line of lines) {
  103. if (line.includes(keyword)) {
  104. extractedData.push(line);
  105. }
  106. }
  107.  
  108. offset += chunkSize;
  109. progressBar.style.width = (offset / file.size * 100) + '%';
  110.  
  111. if (offset < file.size) {
  112. readNextChunk();
  113. } else {
  114. const now = new Date();
  115. const year = now.getFullYear();
  116. const month = (now.getMonth() + 1).toString().padStart(2, '0');
  117. const day = now.getDate().toString().padStart(2, '0');
  118. const hours = now.getHours().toString().padStart(2, '0');
  119. const minutes = now.getMinutes().toString().padStart(2, '0');
  120. const seconds = now.getSeconds().toString().padStart(2, '0');
  121. const formattedDate = `${year}-${month}-${day}_${hours}-${minutes}-${seconds}`;
  122. const blob = new Blob([extractedData.join('\n')], { type: 'text/plain' });
  123. const url = window.URL.createObjectURL(blob);
  124. const a = document.createElement('a');
  125. a.href = url;
  126. a.download = `${keyword}_${formattedDate}.txt`;
  127. a.click();
  128. window.URL.revokeObjectURL(url);
  129. }
  130. };
  131.  
  132. function readNextChunk() {
  133. const blob = file.slice(offset, offset + chunkSize);
  134. reader.readAsText(blob);
  135. }
  136.  
  137. readNextChunk();
  138. } else {
  139. output.textContent = 'Por favor, selecione um arquivo.';
  140. }
  141. }
  142. </script>
  143.  
  144. </body>
  145. </html>
Advertisement
Add Comment
Please, Sign In to add comment