ProxyPool.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /**
  2. * Created by ben on 2017/10/24.
  3. */
  4. const php = require('phpjs');
  5. const Tool = require('../framework/lib/Tool.js');
  6. const dwHttp = require('../framework/lib/dwHttp.js');
  7. const TableHelper = require('../framework/lib/TableHelper.js');
  8. class ProxyPool {
  9. getYYProxyList() {
  10. let proxyList = [
  11. "10.20.60.190:8118",
  12. "10.20.60.225:8118",
  13. "10.20.60.243:8118",
  14. "10.20.60.241:8118",
  15. "10.20.60.170:8118",
  16. "10.20.60.162:8118",
  17. "10.20.60.155:8118",
  18. "10.20.60.87:8118",
  19. "10.20.60.168:8118",
  20. "10.20.60.137:8118",
  21. "10.20.60.136:8118",
  22. "10.20.60.132:8118",
  23. "10.20.60.129:8118",
  24. "10.20.60.128:8118",
  25. "10.20.60.127:8118",
  26. "10.20.60.126:8118",
  27. "10.20.61.250:8118",
  28. "10.20.60.236:8118",
  29. "10.20.60.233:8118",
  30. "10.20.60.232:8118",
  31. "10.20.60.230:8118",
  32. "10.20.60.228:8118",
  33. "10.20.60.227:8118",
  34. "10.20.60.224:8118",
  35. "10.20.61.118:8118",
  36. "10.20.61.98:8118",
  37. "10.20.60.186:8118",
  38. "10.20.60.172:8118",
  39. "10.20.60.171:8118",
  40. "10.20.61.216:8118",
  41. "10.20.61.215:8118",
  42. "10.20.49.190:8118",
  43. "10.20.49.189:8118",
  44. "10.20.60.23:8118",
  45. "10.20.96.171:8118",
  46. "10.20.96.170:8118",
  47. "10.20.96.169:8118",
  48. "10.20.60.250:8118",
  49. "10.20.60.153:8118",
  50. "10.20.60.108:8118",
  51. "10.20.61.117:8118",
  52. "10.20.61.116:8118",
  53. "10.20.61.84:8118",
  54. "10.20.61.83:8118",
  55. ];
  56. return proxyList;
  57. }
  58. async getFreeProxyList() {
  59. return [];
  60. let objHttp = new dwHttp();
  61. let url = 'http://61.160.36.225:8000/?count=10';
  62. let rep = await objHttp.get2(url);
  63. if (rep) {
  64. let list = JSON.parse(rep);
  65. for (let i = 0; i < list.length && i < 100; i++) {
  66. list[i] = `${list[i][0]}:${list[i][1]}`;
  67. }
  68. return list;
  69. } else {
  70. return [];
  71. }
  72. }
  73. async getXProxyList() {
  74. let objHttp = new dwHttp();
  75. let url = 'http://61.160.36.226/spider/ipList';
  76. let rep = await objHttp.get2(url, 3, 3, "HOST:admin.duowan.com");
  77. console.log("XProxyList:" + rep);
  78. if (rep) {
  79. let result = JSON.parse(rep);
  80. if (result.result) {
  81. return result.data.proxyList;
  82. }
  83. }
  84. return [];
  85. }
  86. async getXProxyBest(domain) {
  87. let objHttp = new dwHttp();
  88. let num = 100;
  89. let url = `http://61.160.36.226/spider/bestProxy?num=${num}&domain=${domain}`;
  90. let rep = await objHttp.get2(url, 3, 3, "HOST:admin.duowan.com");
  91. if (rep) {
  92. let result = JSON.parse(rep);
  93. if (result.result) {
  94. return result.data.proxyList;
  95. }
  96. }
  97. return [];
  98. }
  99. async reportProxy(domain, proxy, score) {
  100. let objHttp = new dwHttp();
  101. let url = `http://61.160.36.226/spider/reportProxy?proxy=${proxy}&domain=${domain}&score=${score}`;
  102. let rep = await objHttp.get2(url, 3, 3, "HOST:admin.duowan.com");
  103. if (rep) {
  104. let result = JSON.parse(rep);
  105. if (result.result) {
  106. return result.data;
  107. }
  108. }
  109. return 0;
  110. }
  111. async getProxyList() {
  112. let freeProxyList = await this.getFreeProxyList();
  113. let xProxyList = await this.getXProxyList();
  114. freeProxyList = freeProxyList.concat(xProxyList);
  115. if (ENV === ENV_DEV) {
  116. return freeProxyList;
  117. } else {
  118. let yyProxyList = await this.getYYProxyList();
  119. return yyProxyList.concat(freeProxyList);
  120. }
  121. }
  122. }
  123. module.exports = ProxyPool;