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OAAQ,EAAQ,MAAM,SAAU,EAAK,EAAU,GACzE,GACD,EAAQ,MAAM,EAAS,QAAQ,KAAM,GAAM,SAAQ,SAAU,GACzD,iBAAiB,EACrB,MAEJ,SACe,GAAe,aAClC,GAER,GACJ,IAAG,GAEH,KAAK","file":"/npm/proxy-list-builder@1.0.6/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/proxy-list-builder@1.0.6/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var requestHelper = require('./request-helper')\r\nvar scrapingHelper = require('./scraping-helper')\r\nvar mongoose = require('mongoose')\r\nvar Proxy = require('./models/ProxyModel')\r\nvar meta = require('./meta')\r\nvar cron = require('node-cron');\r\nvar util = require('util')\r\n\r\nmongoose.connect('mongodb://127.0.0.1:27017/proxies', {\r\n    useMongoClient: true\r\n});\r\n\r\nvar db = mongoose.connection;\r\ndb.on('error', console.error.bind(console, 'MongoDB connection error:'));\r\n\r\nvar proxiesAdded = 0\r\nvar proxiesFound = 0\r\nvar insertIfNotExist = function (proxy) {\r\n    Proxy.findOne({\r\n        ip: proxy.ip,\r\n        port: proxy.port\r\n    }, function (err, data) {\r\n        if (err) return;\r\n        proxiesFound++;\r\n        if (!data && proxy.ip != '' && proxy.ip != '0' && proxy.port != '' && proxy.port != '0') {\r\n            var proxyModel = new Proxy(proxy);\r\n            proxyModel.save(function (err, result) {\r\n                proxiesAdded++;\r\n            });\r\n        }\r\n    });\r\n}\r\n\r\nvar printStatus = function () {\r\n    console.log('Proxies Found: ' + proxiesFound)\r\n    console.log('Proxies Added: ' + proxiesAdded)\r\n}\r\n\r\nvar counter = 0\r\nvar task = cron.schedule('0 */15 * * * *', function () {\r\n    console.log('scraping after every 15 minutes');\r\n    proxiesAdded = 0\r\n    proxiesFound = 0\r\n    counter = 0\r\n    var totalRequests = meta.length\r\n    meta.forEach(function (metaObj) {\r\n        metaObj.maxLength ? totalRequests += metaObj.maxLength : totalRequests += 0;\r\n        if (metaObj.maxLength) {\r\n            totalRequests--;\r\n            for (var index = 1; index <= metaObj.maxLength; index++) {\r\n                requestHelper(util.format(metaObj.url, index), metaObj.method, metaObj.body, function (err, response, body) {\r\n                    if (!err) {\r\n                        metaObj.parse(response.request.href, body).forEach(function (proxy) {\r\n                            insertIfNotExist(proxy);\r\n                        });\r\n                    }\r\n                    counter++;\r\n                    if (counter == totalRequests) printStatus()\r\n                })\r\n            }\r\n        } else {\r\n            requestHelper(metaObj.url, metaObj.method, metaObj.body, function (err, response, body) {\r\n                if (!err) {\r\n                    metaObj.parse(response.request.href, body).forEach(function (proxy) {\r\n                        insertIfNotExist(proxy);\r\n                    });\r\n                }\r\n                counter++;\r\n                if (counter == totalRequests) printStatus()\r\n            })\r\n        }\r\n    });\r\n}, false);\r\n\r\ntask.start();"]}