├── .editorconfig ├── .gitignore ├── .jscsrc ├── README.md ├── companies ├── Aras.js ├── Yurtici.js └── index.js ├── index.js ├── package.json └── sample.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | 10 | [*.json] 11 | indent_size = 2 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Commenting this out is preferred by some people, see 24 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 25 | node_modules 26 | 27 | # Users Environment Variables 28 | .lock-wscript 29 | 30 | # ========================= 31 | # Operating System Files 32 | # ========================= 33 | 34 | # OSX 35 | # ========================= 36 | 37 | .DS_Store 38 | .AppleDouble 39 | .LSOverride 40 | 41 | # Thumbnails 42 | ._* 43 | 44 | # Files that might appear on external disk 45 | .Spotlight-V100 46 | .Trashes 47 | 48 | # Directories potentially created on remote AFP share 49 | .AppleDB 50 | .AppleDesktop 51 | Network Trash Folder 52 | Temporary Items 53 | .apdisk 54 | 55 | # Windows 56 | # ========================= 57 | 58 | # Windows image file caches 59 | Thumbs.db 60 | ehthumbs.db 61 | 62 | # Folder config file 63 | Desktop.ini 64 | 65 | # Recycle Bin used on file shares 66 | $RECYCLE.BIN/ 67 | 68 | # Windows Installer files 69 | *.cab 70 | *.msi 71 | *.msm 72 | *.msp 73 | 74 | # Windows shortcuts 75 | *.lnk 76 | -------------------------------------------------------------------------------- /.jscsrc: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "google", 3 | "disallowKeywords": ["with"], 4 | "disallowMultipleLineBreaks": null, 5 | "disallowMultipleVarDecl": null, 6 | "disallowSpacesInsideObjectBrackets": null, 7 | "requireCamelCaseOrUpperCaseIdentifiers": null, 8 | "requireCurlyBraces": null, 9 | "validateIndentation": 4 10 | } 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kargojs 2 | 3 | Türkiye Kargo firmalarından rahatça sorgulama yapabilmek için geliştirilen npm modülü. 4 | 5 | ## Kullanım 6 | 7 | ```js 8 | 9 | var kargojs = require('./index'); 10 | 11 | 12 | kargojs.Yurtici.query("107683143283",function(err,data){ 13 | console.log(err ? err : data); 14 | }) 15 | 16 | 17 | kargojs.Yurtici.getMovements("107683143283",function(err,data){ 18 | console.log(err ? err : data); 19 | }) 20 | 21 | 22 | kargojs.Aras.query("5560228801279",function(err,data){ 23 | console.log(err ? err : data); 24 | }) 25 | 26 | 27 | kargojs.Aras.getMovements("5560228801279",function(err,data){ 28 | console.log(err ? err : data); 29 | }) 30 | 31 | ``` 32 | 33 | ## Aktif kargo firmaları 34 | Şuan için aktif olan firmalar Aras ve Yurtiçi kargo firmalarıdır. Diğer firmaları da yavaş yavaş ekleyeceğim. 35 | 36 | ## Testler 37 | Henüz test yazmadım, bazı yerlerde de saçma sapan hackler kullanarak sonuca ulaşmaya çalıştım. Lütfen ürün ortamında kullanmadan önce inceleyin, saçma bulduğunuz yerler için issue oluşturabilirseniz sevinirim. 38 | -------------------------------------------------------------------------------- /companies/Aras.js: -------------------------------------------------------------------------------- 1 | var Aras = {}, 2 | request = require('request'), 3 | async = require('async'); 4 | 5 | 6 | 7 | /** 8 | * @private 9 | */ 10 | Aras._delete_null_properties = function(test, recurse) { 11 | for (var i in test) { 12 | if (test[i] === null) { 13 | delete test[i]; 14 | } else if (recurse && typeof test[i] === 'object') { 15 | Aras._delete_null_properties(test[i], recurse); 16 | } 17 | } 18 | } 19 | 20 | 21 | /** 22 | * @private 23 | */ 24 | Aras._stripTags = function(str){ 25 | return str.replace(/<(?:.|\n)*?>/gm, ''); 26 | } 27 | 28 | 29 | /** 30 | * @private 31 | */ 32 | Aras._findAndGetRegex = function(regexPattern,subject){ 33 | var findings = regexPattern.exec(subject); 34 | 35 | return !findings ? null : Aras._stripTags(findings[1]); 36 | } 37 | 38 | 39 | /** 40 | * @private 41 | */ 42 | Aras._getShipmentId = function(query,callback){ 43 | request("http://kargotakip.araskargo.com.tr/CargoInfoV3.aspx?code=" + String(query), function(err,response,body){ 44 | if (err) return callback(err); 45 | 46 | var shipmentIdRegex = /shipmentid=(.*)&/g, 47 | shipmentId = Aras._findAndGetRegex(shipmentIdRegex,body), 48 | barcodeRegex = /barcode=(.*)&/g, 49 | barcode = Aras._findAndGetRegex(barcodeRegex,body); 50 | 51 | if(shipmentId && barcode){ 52 | var idsObject = { 53 | shipmentId: shipmentId, 54 | barcode: barcode 55 | } 56 | return callback(null,idsObject); 57 | } else { 58 | return callback(new Error('Hatalı kargo takip numarası')); 59 | } 60 | }) 61 | } 62 | 63 | 64 | /** 65 | * @private 66 | */ 67 | Aras._getCargoDetails = function(shipmentId,callback){ 68 | request("http://kargotakip.araskargo.com.tr/CargoInfoWaybillAndDelivered.aspx?shipmentid=" + String(shipmentId), function(err,response,body){ 69 | if (err) return callback(err); 70 | 71 | var kayitKontrolRegex = /(.*)<\/font>/g, 72 | kayitKontrol = Aras._findAndGetRegex(kayitKontrolRegex,body); 73 | 74 | if(kayitKontrol != null) 75 | return callback(new Error('Kayıt bulunamadı')); 76 | 77 | 78 | var ilkCikisRegex = /(.*)<\/span>/g; 79 | var ilkCikis = Aras._findAndGetRegex(ilkCikisRegex,body); 80 | 81 | var cikisRegex = /(.*)<\/span>/g; 82 | var cikis = Aras._findAndGetRegex(cikisRegex,body); 83 | 84 | var varisRegex = /(.*)<\/span>/g; 85 | var varis = Aras._findAndGetRegex(varisRegex,body); 86 | 87 | var odemeTuruRegex = /(.*)<\/span>/g; 88 | var odemeTuru = Aras._findAndGetRegex(odemeTuruRegex,body); 89 | 90 | var aliciRegex = /(.*)<\/span>/g; 91 | var alici = Aras._findAndGetRegex(aliciRegex,body); 92 | 93 | var kargoCinsRegex = /(.*)<\/span>/g; 94 | var kargoCins = Aras._findAndGetRegex(kargoCinsRegex,body); 95 | 96 | var paketSayiRegex = /(.*)<\/span>/g; 97 | var paketSayi = Aras._findAndGetRegex(paketSayiRegex,body); 98 | 99 | var gonderiTipiRegex = /(.*)<\/span>/g; 100 | var gonderiTipi = Aras._findAndGetRegex(gonderiTipiRegex,body); 101 | 102 | var cikisTarihiRegex = /(.*)<\/span>/g; 103 | var cikisTarihi = Aras._findAndGetRegex(cikisTarihiRegex,body); 104 | 105 | var tasimaIrsaliyeRegex = /(.*)<\/span>/g; 106 | var tasimaIrsaliye = Aras._findAndGetRegex(tasimaIrsaliyeRegex,body); 107 | 108 | var gonderiNoRegex = /(.*)<\/span>/g; 109 | var gonderiNo = Aras._findAndGetRegex(gonderiNoRegex,body); 110 | 111 | var gondericiRegex = /(.*)<\/span>/g; 112 | var gonderici = Aras._findAndGetRegex(gondericiRegex,body); 113 | 114 | var sevkIrsaliyeRegex = /(.*)<\/span>/g; 115 | var sevkIrsaliye = Aras._findAndGetRegex(sevkIrsaliyeRegex,body); 116 | 117 | var durumRegex = /(.*)<\/span>/g; 118 | var durum = Aras._findAndGetRegex(durumRegex,body); 119 | 120 | var teslimAlanRegex = /(.*)<\/span>/g; 121 | var teslimAlan = Aras._findAndGetRegex(teslimAlanRegex,body); 122 | 123 | var teslimTarihiRegex = /(.*)<\/span>/g; 124 | var teslimTarihi = Aras._findAndGetRegex(teslimTarihiRegex,body); 125 | 126 | var arasObj = { 127 | bilgiler: { 128 | 'ilk_cikis_sube': ilkCikis, 129 | 'cikis_sube': cikis, 130 | 'varis_sube': varis, 131 | 'odeme_turu': odemeTuru, 132 | 'alici': alici, 133 | 'kargo_cinsi': kargoCins, 134 | 'paket_sayi': paketSayi, 135 | 'gonderi_tipi': gonderiTipi, 136 | 'cikis_tarihi': cikisTarihi, 137 | 'tasima_irsaliye_no': tasimaIrsaliye, 138 | 'gonderi_no': gonderiNo, 139 | 'gonderici': gonderici, 140 | 'sevk_irsaliye_no': sevkIrsaliye, 141 | }, 142 | durum: { 143 | 'son_durum': durum, 144 | 'teslim_alan': teslimAlan, 145 | 'teslim_tarihi': teslimTarihi 146 | } 147 | } 148 | 149 | return callback(null,arasObj); 150 | 151 | }) 152 | } 153 | 154 | 155 | /** 156 | * @private 157 | */ 158 | Aras._getMovementDetails = function(barcode,callback){ 159 | request("http://kargotakip.araskargo.com.tr/CargoInfoTransactionAndRedirection.aspx?barcode=" + String(barcode), function(err,response,body){ 160 | if (err) return callback(err); 161 | 162 | body = body.replace(//g, ''); 163 | 164 | var tableRegex = /