def search(q): data, dataa = h.bs("https://alquran-indonesia.com/search.php?search=" + q), [] for surat in data.findAll("div", class_="panel panel-default")[:10]: arabic = surat.p.text golongan = surat.find( "div", class_="panel-heading").text[9:][:-7].split("/ ")[1].split(" (")[0] suratt = "Q.S. {}: {}".format( surat.b.text[:-1], surat.find("div", class_="panel-heading").text[9:][:-7].split(":") [1].split(")")[0]) arti = surat.find( "div", class_="pull-left m-left-sm m-top-sm ltr").text[12:][:-11] latin = surat.find("div", class_="tab-pane fade latin").p.text[1:].replace( "\n", "").capitalize() latin = latin[:-1] if latin.endswith(" ") else latin audio = surat.find("button", {"id": "nextStep"}).get("data-selector") try: asbabun = surat.find("div", {"id": "message89"}).p.text except: asbabun = "-" dataa.append({ "surat": suratt, "golongan": golongan, "ayat": { "arabic": arabic, "latin": latin, "arti": arti, "audio": audio }, "asbabunNuzul": asbabun }) h.pj(dataa)
def catOfTheDay(): data = h.bs("http://www.funnycatpix.com/") title = h.bs( data.base.get("href") + data.find("div", class_="catphoto").a.get("href")).title.text cat = data.base.get("href") + data.img.get("src") h.pj({"title": title, "image": cat})
def cariKost2(query): data,dataa=h.bs("https://m.infokost.id/search?q={}&checkin=2019-07-07&type=kost&price_type=monthly&order=&price=0-50000000&ac=false".format(query)).find("div",class_="result-search"),[] try: niherror=data.find("div",class_="alert alert- margin-top-20 text-center").text h.pj({"error":"Pencarian kost {} tidak ditemukan.".format(query)}) except: for kost in data.findAll("div",class_="box-search"): title=kost.h2.text kamarr=[] link=kost.a.get("href") alamat=kost.find("div",class_="box-address").text[17:][:-12] info=h.bs(link) images=[img.get("src") for img in info.find("div",class_="detail-images").findAll("img")] fulldesc="".join([desc.text[56:][:-29] for desc in info.findAll("div",class_="full-width")[-1:]]) if fulldesc==" - ":fulldesc.replace(" ","") for kamar in info.find("div",class_="container-detail").findAll("div",class_="room-row"): kamarw=kamar.div.text[13:][:-8] fasilitas=[fas.text for fas in kamar.find("div",class_="row").findAll("p")] desc=kamar.find("div",class_="room-subtitle").text[14:].replace(" Deskripsi","").replace(" \n ","\n").replace(" ","").replace(" ","") if desc.endswith("\n"):desc=desc[:-1] desc=desc.split("\n") images=[img.get("src") for img in info.findAll("img",{"alt":kamarw})] harga=kamar.find("div",class_="right room-price-detail").text kamarr.append({"kamar":kamarw,"fasilitas":fasilitas,"desc":desc,"harga":harga}) dataa.append({"title":title,"link":link,"images":images,"alamat":alamat,"fullDesc":fulldesc,"kamar":kamarr}) return json.dumps(dataa)
def loker(): data, dataa = h.bs(url + "/search").find("ul", class_="opportunities-list"), [] for ker in data.findAll("li", class_="opportunity opportunity-search-click"): perusahaan = ker.h3.text link = url + ker.get("data-url") profesi = ker.h2.text.title() if profesi.endswith(" "): profesi = profesi[:-1] gaji = ker.find("span", class_="tdd-salary").text lokasi = ker.find("div", class_="tdd-location").text info = h.bs(link) infoo = info.findAll("div", class_="bm-opportunity-stat__value") pengalaman = infoo[2].text jobfunction = infoo[1].text levelkarir = infoo[3].text edukasi = infoo[4].text info2 = info.findAll("section", class_="b-matte__content") desc = info2[0].text req = info2[1].text dataa.append({ "perusahaan": perusahaan, "link": link, "profesi": profesi, "gaji": gaji, "lokasi": lokasi, "pengalaman": pengalaman, "jobFunction": jobfunction, "levelKarir": levelkarir, "edukasi": edukasi, "desc": desc, "syarat": req }) h.pj(dataa)
def randomFunnyCatPictures(): data, dataa = h.bs("https://funnycatsite.com"), [] for cat in data.main.findAll("img"): image = data.base.get("href") + cat.get("src").replace( "thumbs", "pictures").replace("_s", "").lower() title = cat.get("alt") dataa.append({"title": title, "image": image}) h.pj(random.choice(dataa))
def getRandomQuotes(): data,dataa=h.bs("https://best-quotations.com/tyxaio.php"),[] for q in data.findAll("td",class_="quote"): quote=q.b.text wil=q.a.text if "," in wil:au=wil.split(",")[0] else:au=wil quote=quote[:-2]+"." if quote.endswith(" .") else quote categ=", ".join([c.text for c in q.findAll("li")]) dataa.append({"quote":quote,"author":au,"category":categ}) h.pj(h.rc(dataa))
def getRamalan(zodiak): if zodiak.title() in zodiaks: data=h.bs("http://gemintang.com/ramalan-bintang-setiap-hari/ramalan-{}-hari-ini/".format(zodiak)) info=data.findAll("td",{"colspan":2}) ramalan=info[1].text[8:].split(" \xa0")[0] hidup=ramalan.split(" Keuangan: ")[0] keuangan=ramalan.split("Keuangan: ")[1].split(" Asmara:")[0].capitalize() asmara=ramalan.split("Asmara: ")[1].capitalize() luckyn=info[2].findAll("td")[2].text[1:][:-1] h.pj({"zodiak":zodiak.title(),"ramalan":{"hidup":hidup,"keuangan":keuangan,"asmara":asmara,"nomorKeberuntungan":luckyn}}) else: h.pj({"error":"Tidak ada zodiak {}. Zodiak yang tersedia hanya {}.".format(zodiak,", ".join(zodiaks))})
def getSimpleWorldClock(maximum=144): start=time.time() data,dataa=h.bs(wil+"/worldclock/?sort=0").table,[] for clock in data.findAll("a")[:maximum]:dan.append(clock.text+"///"+wil+clock.get("href")) dan.sort() for clockk in dan: info=clockk.split("///");city,link=info[0],info[1] infoo=h.bs(link) dtime=infoo.find("span",{"id":"ctdat"}).text+", "+infoo.find("span",class_="h1").text dataa.append({"city":city,"datetime":dtime}) h.pj(dataa) print("Execution time: {} seconds.".format(round(time.time() - start)))
def getData(): data, dataa = h.bs("http://filmindonesia.or.id/movie/viewer").tbody, [] for film in data.findAll("tr"): r = film.td.text filmm = film.a link, title = filmm.get("href"), filmm.text pen = film.findAll("td")[-1].text dataa.append({ "rank": r, "title": title, "link": link, "penonton": pen }) h.pj(dataa)
def getDetailWorldClock(maximum=144): start=time.time() data,dataa=h.bs(wil+"/worldclock/?sort=0").table,[] for clock in data.findAll("a")[:maximum]:dan.append(clock.text+"///"+wil+clock.get("href")) dan.sort() for clockk in dan: info=clockk.split("///") link=info[1] infoo=h.bs(link) time=infoo.find("span",class_="h1").text tz=infoo.find("span",{"id":"cta"});tz="{} ({})".format(tz.a.get("title"),tz.text) dt=infoo.find("span",{"id":"ctdat"}).text info2=[x.text.split(": ")[1] for x in infoo.find("div",class_="five columns").findAll("p")] city,coun,ll,cur,lang,dial=info[0],info2[0],info2[1],info2[2],info2[3],info2[4].split(" - ")[0] dataa.append({"city":city,"link":link,"country":coun,"latLong":ll,"currency":cur,"language":lang,"dialCode":dial}) h.pj(dataa) print("Execution time: {} seconds.".format(round(time.time() - start)))
def randomFML(): return h.pj({ "fml": random.choice([ fml.text.split(" FML")[0].replace("\n", "") for fml in h.bs("https://www.fmylife.com/random").findAll( "a", class_="article-link") ]) })
def findApps(query): data,dataa=h.bs(url+"/store/search?q={}&c=apps".format(query)),[] for app in data.findAll("div",class_="Vpfmgd"): image=app.img.get("data-src") infoo=app.findAll("a")[2] link=url+infoo.get("href") title=infoo.text developer=app.find("a",class_="mnKHRc").text desc=app.find("div",class_="b8cIId f5NCO").text info=h.bs(link) rated="{}/5 ({})".format(app.find("div",{"role":"img"}).get("aria-label").split(" ")[1].split(" ")[0],info.findAll("span",class_="")[2].text) genre=info.find("a",{"itemprop":"genre"}).text rating=info.find("img",class_="T75of E1GfKc").get("alt").split(" ")[1] fulldesc=info.find("meta",{"itemprop":"description"}).get("content") email=info.find("a",class_="hrTbp euBY6b").text version=info.findAll("span",class_="htlgb")[6].text dataa.append({"title":title,"link":link,"image":image,"developer":developer,"shortDesc":desc,"rated":rated,"rating":rating,"genre":genre,"version":version,"fullDesc":fulldesc,"emailDev":email}) h.pj(dataa)
def getRamalan(zodiak): if zodiak.title() in zodiaks: data = h.bs( "http://gemintang.com/ramalan-bintang-setiap-hari/ramalan-{}-hari-ini/" .format(zodiak)) info = data.findAll("td", {"colspan": 2})[1] ramalan = info.text[8:].split(". \n")[0] + "." luckyn = data.findAll("table")[1].findAll("tr")[1].td.text[1:][:-1] h.pj({ "zodiak": zodiak.title(), "ramalan": ramalan, "nomorKeberuntungan": luckyn }) else: h.pj({ "error": "Tidak ada zodiak {}. Zodiak yang tersedia hanya {}.".format( zodiak, ", ".join(zodiaks)) })
def randomFunnyCatVideo(): data, dataa = h.bs("http://www.catsvscancer.org/section/video/"), [] for vids in data.findAll("div", class_="video-btn-wrapper"): vid = h.bs(vids.a.get("href")) title = vid.h3.text[:-1] link = vid.iframe.get("src") if "facebook" in link: x = link.split("href=")[1].split("&show")[0] link = h.bs( "https://www.videofk.com/facebook-video-download/search?url={}&select=facebook" .format(x)) link = link.findAll("a")[9].get("href") else: id = link.split("embed/")[1].split("?")[0] try: linkk = h.ytmp4(id) except: id = id[:-5].replace("//", "") linkk = h.ytmp4(id) dataa.append({"title": title, "video": linkk}) h.pj(random.choice(dataa))