import os
from bs4 import BeautifulSoup


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


def soupping(file):
    with open(file, 'rb') as f:
        file = f.read()
    return BeautifulSoup(file)


def get_abs_path(path):
    return os.path.join(BASE_DIR, path)


idar_soup = soupping(get_abs_path("html/rumah+sakit"))
angka_soup = soupping(get_abs_path("html/angka123"))
pegon_soup = soupping(get_abs_path("html/pegon_suratman"))

@@ -3,16 +3,32 @@
 port os%0A
+import requests%0A
 from bs4
@@ -55,101 +55,374 @@
 p%0A%0A%0A
-BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))%0A%0A%0Adef soupping(file):%0A
+class LayananValueError(ValueError):%0A    def __init__(self, message=None):%0A        super(LayananValueError, self).__init__(message)%0A        self.message = message%0A%0A%0ABASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))%0A%0A%0Adef soupping(file):%0A    if file.startswith(%22http%22):%0A        resp = requests.get(file)%0A        file = resp.content%0A    else:%0A    
     
@@ -449,16 +449,20 @@
 ) as f:%0A
+    
         
@@ -739,12 +739,1231 @@
 suratman%22))%0A
+%0A%0Adef build_url(query, layanan=None):%0A    %22%22%22Return url pencarian sesuai dengan *query* yang dimasukkan.%0A    layanan ketika None maka akan terjadi pengecekan query,%0A    kalau query adalah integer atau seperti integer maka berikan kembalian%0A    ANGKA_URL,%0A    kalau string maka secara default akan direfrensikan ke INDO_URL.%0A    Bila tidak None, maka tergantung dengan layanan yang diminta.%22%22%22%0A%0A    # syntactic sugar%0A    is_angka = isinstance(query, int) or query.isdigit()%0A%0A    ANGKA_URL = %22http://qaamus.com/terjemah-angka/%7Bnumber%7D/angka%22.format(%0A        number=query)%0A    INDO_URL = %22http://qaamus.com/indonesia-arab/%7Bquery%7D/1%22.format(%0A        query=%22+%22.join(query.split()))%0A    PEGON_URL = 'http://qaamus.com/terjemah-nama/%7Bpegon%7D'.format(%0A        pegon=query)%0A%0A    layanan_mapping = dict(%0A        (('angka', ANGKA_URL),%0A            ('idar', INDO_URL),%0A            ('pegon', PEGON_URL))%0A        )%0A%0A    if not layanan:%0A        if is_angka:%0A            url = ANGKA_URL%0A        elif isinstance(query, str):%0A            url = INDO_URL%0A    else:%0A        if layanan in layanan_mapping:%0A            url = layanan_mapping%5Blayanan%5D%0A        else:%0A            raise LayananValueError(%22Layanan tidak ditemukan%22)%0A%0A    return url%0A

add build_url, and soupping using requests if startswith http