Created
March 3, 2017 13:48
-
-
Save mzaini30/ccad89433e0512b54a223e89d2424e01 to your computer and use it in GitHub Desktop.
Menggabungkan semua kontak ke 1 html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob, re | |
lokasi = "/sdcard/python/kontak/" | |
folder = "input" | |
enter = "\n\n" | |
header = open(lokasi+"_component/header.txt").read() | |
footer = open(lokasi+"_component/footer.txt").read() | |
output = open(lokasi+"output.html", "w") | |
kontak = glob.glob(lokasi+folder+"/*") | |
nama = kontak[:] | |
fkontak = nama[:] | |
for n, x in enumerate(nama): | |
nama[n] = x[:-4] | |
nama[n] = re.sub(r""+lokasi+folder+"/", r"", nama[n]) | |
for n, x in enumerate(kontak): | |
fkontak[n] = open(x).read() | |
fkontak[n] = re.sub(r"\+62", r"0", fkontak[n]) | |
fkontak[n] = re.findall(r"\d+", fkontak[n]) | |
hasil = [] | |
hasil.append(header) | |
hasil.append(enter) | |
for n, x in enumerate(nama): | |
hasil.append("# "+x) | |
hasil.append(enter) | |
hasil.append(fkontak[n]) | |
hasil.append(enter) | |
hasil.append(footer) | |
hasil = "".join(str(x) for x in hasil) | |
output.write(hasil) | |
print "done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>kontak</title> | |
<link rel="stylesheet" href="bin/w3.css"/> | |
<style> | |
textarea.markdown{display:none;} | |
</style> | |
</head> | |
<body> | |
<div class="w3-container"> | |
<div class="markdown"></div> | |
</div> | |
<textarea class="markdown"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>kontak</title> | |
<link rel="stylesheet" href="bin/w3.css"/> | |
<style> | |
textarea.markdown{display:none;} | |
</style> | |
</head> | |
<body> | |
<div class="w3-container"> | |
<div class="markdown"></div> | |
</div> | |
<textarea class="markdown"> | |
# 3 | |
['2', '1', '3', '3', '084491648251', '1'] | |
# a Mbak Nur Poligon Primer 4 | |
['2', '1', '4', '4', '081537153855', '341'] | |
# Abid | |
['2', '1', '082242658153', '3'] | |
</textarea> | |
<script src="bin/jquery.min.js"></script> | |
<script src="bin/marked.min.js"></script> | |
<script> | |
$("div.markdown").html(marked($("textarea.markdown").val())) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment