bikin perangkat lunak periksa ongkos kirim jne tiki pos dengan bahasa python
perangkat lunak periksa ongkir jne tiki pos
kemarin timbul inspirasi di logikakanan aku buat bikin sesuatu perangkat lunak periksa ongkir buat semua jharapan pengiriman. mengingat jharapan pengiriman yang adanya di indonesia banyak, tersebutkan agak ribet jijikalau sesegera bisa jadi buka web masing-masing jharapan pengiriman cuma buat periksa ongkir. apakahlagi buat membandingkan mana ongkos kirim yang termurah dari masing-masing jharapan pengiriman. lalu timbullah impian buat bikin perangkat lunak sederhana yang mampu periksa ongkos kirim jne tiki serta pos dan merupakan juga. sesudah menelusuri sebagiankah referensi di internet, aku memperolehkan website http://rajaongkir.com/. website ini amat menarik, kita mampu melaksanakan periksa ongkos kirim jne tiki pos esl pcp serta rpx dan merupakan juga. aku tertarik buat menyidik jauh prosesnya lebih dalam.
akhirnya sesudah berselancar lebih lama aku baru sadanyar jikalau http://rajaongkir.com/ menyediakan api (application ametodeming interface) yang mampu kita gunakan buat bikin perangkat lunak periksa ongkir mirip. nah, api ialah seperpaduan perintah, khasiat serta protokol yang bisa dipakai oleh ametodemer saat membangun perangkat lunak buat proses operasi terjelas saja. api mebisa jadikan ametodemer buat memakaikan khasiat stkamur buat berinteraksi dengan proses operasi lain. jadi intisarinya ialah begini, saat aku ingin periksa ongkir dari kota a ke kota b, aku tak memperlukan database ongkir. data ongkir dari kota a ke kota b mampu aku ambil dari api raja ongkir. nah, api ini mampu diakses dari perangkat lunak terhadapnya platform apakahpun baik itu desktop application, kendaraan beroda empate application maupun perangkat lunak berdasar web.
application ametodeming interface
application ametodeming interface
nah buat level awal aku mencoba bikin perangkat lunak periksa ongkos kirim ini memakaikan bahasa python dengan interface cli. oh ya, buat mampu mengakses api yang disediakan raja ongkir kita sesegera bisa jadi memiliki api key. api key ibaratnya ialah password yang kita gunakan supaya mampu mengakses data. buat menerima api key semetode gratis silahkan daftar pribadi di websitenya. sesudah menerima api key serta membaca dokumentasi lengkapnya aku mulai coding. list source code lengkap dari perangkat lunak yang aku buat ialah sebagai berikut :
import http.client
import json
harapanl = input('kota harapanl : ')
sharapanran = input('kota sharapanran : ')
berat = int(input('berat (gram) : '))
jharapan = int(input('1.tiki 2.jne 3.pos (tekan angka) :'))
list_kota = ["aceh barat","aceh barat daya","aceh besar","aceh jaya","aceh selatan",
"aceh singkil","aceh tamiang","aceh tengah","aceh tenggara","aceh timur",
"aceh utara","agam","alor","ambon","harapanhan","asmat","badung","balangan",
"balikpapakahn","bkamu aceh","bkamur lampung","bandung","bandung",
"bandung barat","banggai","banggai kepulauan","bangka","bangka barat",
"bangka selatan","bangka tengah","bangkalan","bangli","banjar","banjar",
"banjarbaru","banjarmasin","banjarnegara","bantaeng","bantul",
"banyuasin","banyumas","banyuwangi","barito kuala","barito selatan",
"barito timur","barito utara","barru","batam","batang",
"batang hari","batu","batu bara","bau-bau","bekasi",
"bekasi","belitung","belitung timur","belu","bener meriah",
"bengkalis","bengkayang","bengkulu","bengkulu selatan","bengkulu tengah",
"bengkulu utara","berau","biak numfor","bima","bima",
"binjai","bintan","bireuen","bitung","blitar",
"blitar","blora","boalemo","bogor","bogor",
"bojonegoro","bolaang mongondow (bolmong)","bolaang mongondow selatan","bolaang mongondow timur","bolaang mongondow utara",
"bombana","bondowoso","bone","bone bolango","bontang",
"boven digoel","boyolali","brebes","bukittinggi","buleleng",
"bulukumba","bulungan (bulongan)","bungo","buol","buru",
"buru selatan","buton","buton utara","ciamis","cianjur",
"cilacap","cilegon","cimahi","cirebon","cirebon",
"dairi","deiyai (deliyai)","deli sersertag","demak","denpharapanr",
"depok","dharmasraya","dogiyai","dompu","donggala",
"dumai","empat lawang","ende","enrekang","fakfak",
"flores timur","garut","gayo lues","gianyar","gorontalo",
"gorontalo","gorontalo utara","gowa","gresik","grobogan",
"gunung kidul","gunung mas","gunungsitoli","halmahera barat","halmahera selatan",
"halmahera tengah","halmahera timur","halmahera utara","hulu sungai selatan","hulu sungai tengah",
"hulu sungai utara","humbang hasundutan","indragiri hilir","indragiri hulu","indramayu",
"intan jaya","jakarta barat","jakarta pusat","jakarta selatan","jakarta timur",
"jakarta utara","pukulbi","jayapura","jayapura","jayawijaya",
"jember","jembrana","jeneponto","jepara","jombang",
"kaimana","kampar","kapuas","kapuas hulu","karanganyar",
"karangasem","karawang","karimun","karo","katingan",
"kaur","kayong utara","kebumen","kediri","kediri",
"keerom","kendal","kendari","kepahiang","kepulauan anambas",
"kepulauan aru","kepulauan mentawai","kepulauan meranti","kepulauan sangihe","kepulauan seribu",
"kepulauan siau tagulkamung biaro (sitaro)","kepulauan sula","kepulauan talaud","kepulauan yapen (yapen waropen)","kerinci",
"ketapakahng","klaten","klungkung","kolaka","kolaka utara",
"konawe","konawe selatan","konawe utara","kotabaru","kotamobagu",
"kotawaringin barat","kotawaringin timur","kuantan singingi","kubu raya","kudus",
"kulon progo","kuningan","kupang","kupang","kutai barat",
"kutai kartanegara","kutai timur","labuhan batu","labuhan batu selatan","labuhan batu utara",
"lahat","lamkamuu","lamongan","lampung barat","lampung selatan",
"lampung tengah","lampung timur","lampung utara","lkamuk","kunot",
"langsa","lanny jaya","lebak","lebong","lembata",
"lhokseumawe","lima puluh koto/kota","lingga","lombok barat","lombok tengah",
"lombok timur","lombok utara","lubuk linggau","lumajang","luwu",
"luwu timur","luwu utara","madiun","madiun","magelang",
"magelang","magetan","majalengka","majene","tersebutkanssar",
"malang","malang","malinau","maluku barat daya","maluku tengah",
"maluku tenggara","maluku tenggara barat","mamharapan","mamberamo raya","mamberamo tengah",
"mamuju","mamuju utara","manado","mkamuiling natal","manggarai",
"manggarai barat","manggarai timur","manokwari","manokwari selatan","mappi",
"maros","mataram","maybrat","meserta","melawi",
"merangin","merauke","mestes","metro","mimika",
"minahharapan","minahharapan selatan","minahharapan tenggara","minahharapan utara","mojokerto",
"mojokerto","morowali","muara enim","muaro pukulbi","muko muko",
"muna","murung raya","musi banyuasin","musi rawas","nabire",
"nagan raya","nagekeo","natuna","nduga","ngadanya",
"nganjuk","ngawi","nias","nias barat","nias selatan",
"nias utara","nunukan","ogan ilir","ogan komering ilir","ogan komering ulu",
"ogan komering ulu selatan","ogan komering ulu timur","pacitan","pasertag","pasertag lawas",
"pasertag lawas utara","pasertag panjang","pasertag parisafe","pasertag sinspirasimpuan","psupaya alam",
"pakpak bharat","pakuno raya","palembang","palopo","palu",
"pamekharapann","pandeglang","pangkamuran","pangkajene kepulauan","pangkal pinang",
"paniai","parepare","parisafe","parigi moutong","passafe",
"passafe barat","paser","pasuruan","pasuruan","pati",
"payakumbuh","pegunungan arfak","pegunungan bintang","pekalongan","pekalongan",
"pekanbaru","pelalawan","pemalang","pematang siantar","penapukul paser utara",
"pesawaran","pesisir barat","pesisir selatan","pidie","pidie jaya",
"pinrang","pohuwato","polewali mkamur","ponorogo","pontianak",
"pontianak","poso","prabumulih","pringsewu","probolinggo",
"probolinggo","pulang pisau","pulau morotai","puncak","puncak jaya",
"purbalingga","purwakarta","purworejo","raja ampat","rejang lebong",
"rembang","rokan hilir","rokan hulu","rote ndao","skakak",
"sabu raijua","salatiga","setararinda","sambas","samosir",
"sampang","sanggau","sarmi","sarolangun","sawah lunto",
"sekadanyau","selayar (kepulauan selayar)","seluma","semarang","semarang",
"seram bagian barat","seram bagian timur","serang","serang","sersertag bedagai",
"seruyan","siak","sibolga","sinspirasinreng rappang/rapakahng","sidoarjo",
"sigi","sijunjung (sawah lunto sijunjung)","sikka","simalungun","simeulue",
"singkawang","sinjai","sintang","situbondo","sleman",
"solok","solok","solok selatan","soppeng","sorong",
"sorong","sorong selatan","sragen","subang","subulussalam",
"sukabumi","sukabumi","sukamara","sukoharjo","sumba barat",
"sumba barat daya","sumba tengah","sumba timur","sumbawa","sumbawa barat",
"sumesertag","sumenep","sungaipenuh","supiori","surabaya",
"surakarta (solo)","tabalong","tabanan","tnalarar","tambrauw",
"tana tidung","tana toraja","tanah bumbu","tanah datar","tanah laut",
"tangerang","tangerang","tangerang selatan","tanggamus","tanjung balai",
"tanjung jabung barat","tanjung jabung timur","tanjung pinang","tapakahnuli selatan","tapakahnuli tengah",
"tapakahnuli utara","tapin","tminuman beralkoholan","tasikmalaya","tasikmalaya",
"tebing tinggi","tebo","tegal","tegal","teluk bintuni",
"teluk wondama","temanggung","ternate","tidore kepulauan","timor tengah selatan",
"timor tengah utara","toba samosir","tojo una-una","toli-toli","tolikara",
"tomohon","toraja utara","trenggalek","tual","tuban",
"tulang bawang","tulang bawang barat","tulungagung","wajo","wakatobi",
"waropen","way kanan","wonogiri","wonosobo","yahukimo",
"yalimo","yogyakarta"]
origin_id = list_kota.index(harapanl) + 1;
dest_id = list_kota.index(sharapanran) + 1;
str_jharapan = ""
if jharapan == 1:
str_jharapan = "tiki"
elif jharapan == 2:
str_jharapan = "jne"
elif jharapan == 3:
str_jharapan = "pos"
conn = http.client.httpconnection("rajaongkir.com")
payload = "origin="+str(origin_id)+"&destination="+str(dest_id)+"&weight="+str(berat)+"&courier="+str_jharapan
headers = {
'key': "e499b7e4456fadanyaasd897asd987asd987asd98",
'content-type': "application/x-www-form-urlencoded"
}
conn.request("post", "/api/starter/cost", payload, headers)
rawreply = conn.getresponse().read()
reply = json.loads(rawreply.decode())
yang akan terjadi = reply['rajaongkir']['results']
print("pengiriman dari :",reply['rajaongkir']['origin_details']['city_name'],
" ke :",reply['rajaongkir']['destination_details']['city_name'],
" berat :",reply['rajaongkir']['query']['weight'],"gram")
for item1 in yang akan terjadi:
print("jharapan :",item1['name'])
yang akan terjadi2 = item1['costs']
for item2 in yang akan terjadi2:
str_out = 'layanan : '
str_out += item2['service']
yang akan terjadi3 = item2['cost']
for item3 in yang akan terjadi3:
str_out += ' harga : rp.'
str_out += str(item3['value'])
print(str_out)
demo ametode periksa ongkos kirim jne tiki serta pos mampu ditinjau diangkuth ini :
cek ongkos kirim jne
periksa ongkos kirim jne
selanjutnya pengembangan perangkat lunak periksa ongkos kirim jne tiki serta pos ini akan aku buat menjadi kendaraan beroda empate application terhadapnya android serta ios. next, tunggu kelanjutan dari project ini
http://www.telekomers.com/2016/04/download-aplikasi-cek-ongkos-kirim.html