def _get_completions(self, data): cs = [] root = fromstring(data) headings = root.findall("div")[1:-1] for h in headings: title = h.find("p").text listE = h.getnext() if listE.tag == 'ul': if "Categor" in title: req_type = FarnellSearch.R_CATEGORY elif "Manufactur" in title: req_type = FarnellSearch.R_MANUFACTURER else: # what is this heading? something new and exciting, no # doubt # some way to flag possible new things needed? continue for a in listE.findall(".//a"): url = a.get('href') name = a.xpath("string()").strip() try: desc, name = name.rsplit(" > ", 1) except ValueError: desc = None cs.append( mnemory.CompletionResult(name, url=url, category=title, description=desc, req_type=req_type)) else: # this is a product table for tr in listE.findall(".//tr"): left = tr.find("td[@id='leftcolumn']/a") url = left.get("href") name = left.xpath("string()").strip() desc = tr.find("td[@id='contentwrapper']/a").xpath( "string()").strip() cs.append( mnemory.CompletionResult( name, url=url, category=title, description=desc, req_type=FarnellSearch.R_PRODUCT)) return cs
def _get_completions(self, data): data = loads(data) cs = [mnemory.CompletionResult(c['input']) for c in data['results']] return cs
def parse(x): symbol = x['t'] name = x['n'] exchange = x['e'] return mnemory.CompletionResult(symbol, description="%s - %s" % (name, exchange))
def _get_completions(self, data): data = loads(data) # the basic completions - not the "node" results simple_compls = data[1] compls = [mnemory.CompletionResult(x) for x in simple_compls] return compls
def _get_completions(self, data): # ugh, no quotes in the "JSON", just load the array result = data_utils.stringLongestBetween(data, "[", "]", True) result = json.loads(result) cs = [mnemory.CompletionResult(c) for c in result] return cs
def _get_completions(self, data): result = data_utils.stripJsonp(data) t = json.loads(result) cs = [mnemory.CompletionResult(c) for c in t['s']] return cs
def _get_completions(self, result): result = data_utils.stripJsonp(result) result = json.loads(result) cs = [mnemory.CompletionResult(c) for c in result['res']['sug']] return cs
def _get_completions(self, data): cs = [] # this is pretty ugly but it gets us the right results for r in data.split("this.txtBox.value%3D")[1:]: quoted = r.split("%22", 1)[0] kw = unquote(quoted) cs.append(kw) cs = [mnemory.CompletionResult(c) for c in cs] return cs
def parse(typ, cs): res = [] for c in cs: if typ == "query": url = None # use the req url elif typ == "part" or typ == "brand": url = self.base + c['octopart_url'] elif typ == "category": args = ["category_uids", c['uid']] url = ( "https://octopart.com/search?filter%5Bfields%5D%5B" + args[0] + "%5D%5B%5D=" + args[1]) res.append( mnemory.CompletionResult(c['text'], url=url, category=typ)) return res
def _get_completions(self, data): data = loads(data) cs = [mnemory.CompletionResult(x) for x in data[1]] return cs
def parse(entry): kwd, uid = entry['value'].split("##", 1) return mnemory.CompletionResult(kwd.strip(), url=uidUrl % uid)
def process(res): res = html.unescape(res.replace("<b>", "").replace("</b>", "")) return mnemory.CompletionResult(res)
def _get_completions(self, data): data = self.stripJsonp(data) result = loads(data) return [mnemory.CompletionResult(c[0]) for c in result[1]]
def parseResult(e): res = mnemory.CompletionResult(e['title'], category=e['type'], url=self.getRequestUrl(e['mid'])) return res
def process(keyword): c = mnemory.CompletionResult(keyword) return c
def _get_completions(self, data): data = loads(data) keys = [s['value'] for s in data] return [mnemory.CompletionResult(key) for key in keys]