def fetch_page(url): try: search.get(url) except: res = requests.get(url) bs = bs4.BeautifulSoup(res.content) entries = bs.find('div', attrs={'id': 'entries_list'}).findAll('a') for url in entries: if url and url['href'].startswith('/memes/'): urls.add(base_url + url['href'])
def GET(self, format): if not format: format = '.json' input = web.input(q='') res = search.get(input.q, db.slave) files = [] for f in res: del(f['date']) files.append(f) return simplejson.dumps(files)
def GET(self, format): if not format: format = '.json' input = web.input(q='') res = search.get(input.q, db.slave) files = [] for f in res: del (f['date']) files.append(f) return simplejson.dumps(files)
def GET(self, id): f = search.get_by_id(id, db.slave) if f.title and f.artist: title = "%s : %s" % (f.artist, f.title) related = search.get(f.artist, db.slave) else: title = f.filename import re q = re.sub('[^a-zA-Z ]+', ' ', f.filename[:-4]) q = [t[:5] for t in q.split(' ') if t.strip()] if len(q) > 2: q = "%s %s" % (q[0], q[1]) else: q = ' '.join(q) related = search.get(q, db.slave) related = [x for x in related if x.id != int(id)] url = "%s://%s" % (web.ctx['protocol'], web.ctx['host']) embedded = """<object type="application/x-shockwave-flash" data="%s/static/player_mp3.swf" width="200" height="20"><param name="movie" value="%s/static/player_mp3.swf" /><param name="FlashVars" value="mp3=%s/media/%d&showstop=1" /></object>""" % (url, url, url, int(id)) return render.view(f, related, embedded, title)
def GET(self, id): f = search.get_by_id(id, db.slave) if f.title and f.artist: title = "%s : %s" % (f.artist, f.title) related = search.get(f.artist, db.slave) else: title = f.filename import re q = re.sub('[^a-zA-Z ]+', ' ', f.filename[:-4]) q = [t[:5] for t in q.split(' ') if t.strip()] if len(q) > 2: q = "%s %s" % (q[0], q[1]) else: q = ' '.join(q) related = search.get(q, db.slave) related = [x for x in related if x.id != int(id)] url = "%s://%s" % (web.ctx['protocol'], web.ctx['host']) embedded = """<object type="application/x-shockwave-flash" data="%s/static/player_mp3.swf" width="200" height="20"><param name="movie" value="%s/static/player_mp3.swf" /><param name="FlashVars" value="mp3=%s/media/%d&showstop=1" /></object>""" % ( url, url, url, int(id)) return render.view(f, related, embedded, title)
def api(q): es_meme = None wit_res = ses.get(WIT_URL + quote(q)) if wit_res.status_code == 200: wit_json = wit_res.json() for outcome in wit_json['outcomes']: if outcome['confidence'] < 0.4: break intent = outcome['intent'] if intent in intent_memes: url = random.choice(intent_memes[intent]) try: es_meme = search.get(url) except: know_your_meme = KnowYourMeme() source = know_your_meme.get_meme_from_url(url) data = source.get_namespace() search.submit(url, data) es_meme = search.get(url) # do a fuzzy search if not es_meme: es_meme = search.search(q)[0] return jsonify({ 'author': 'George', 'body': """ <p> <a href='{url}' title="{title}"><img src='{main_img}' alt="{title}" /></a> </p> """.format(**es_meme['_source']), })
def guestlike(guestid): guestid = int(guestid) idlist, goodslist, actionlist = reader.search() dataSet = reader.data_handle(idlist, goodslist) L, supportData = apriori.apriori(dataSet, minSupport=0.2) rule = apriori.gen_rule(L, supportData, minConf=0.7) glike = search.search(search.PowerSetsBinary(search.get(guestid, idlist, goodslist, actionlist)), rule) print(glike) guestlike = [] conn = pymysql.connect(host='wxs.chinaeast.cloudapp.chinacloudapi.cn', user='******', password='******', port=3306, db='demo') cur = conn.cursor() for i in glike: j = str(i) + '%' sql3 = " SELECT `goods_id`,`goods_name`,`goods_price` FROM goods_information " \ "WHERE `goods_id` like '%s'" % (j) cur.execute(sql3) u3 = cur.fetchone() guestlike.append(u3) conn.close() return guestlike
def GET(self): input = web.input(q='') files = search.get(input.q, db.slave) return render.search(files, query=input.q, title='Search')
def search_title(title): if request.method == 'GET': results = search.get(title) return jsonify({"results": {"mb": results[0], "sj": results[1]}}), 200 else: return "Failed", 405