コード例 #1
0
    def do_query(self, args, opt=None):

        args = self.split_positionals(args, ["query","search"])
        print "loading",self.url.format(args[0].upper())

        self.page = engine.Page(self.url.format(args[0].upper(), load=True))
        self.lpr(self.page)
コード例 #2
0
    def do_query(self, args, opt=None):

        args = self.split_positionals(args, ["query", "search"])

        self.results = Questions(args[0], [])

        self.page = engine.Page(self.search_url,
                                params={"q": args[0]},
                                load=True)
        self.lpr(self.page)
コード例 #3
0
ファイル: wikipedia.py プロジェクト: krornus/webcli
    def do_query(self, args, opt=None):

        args = self.split_positionals(args, ["query", "search"])

        self.page = engine.Page(self.search_url,
                                params={
                                    "search": args[0],
                                    "fulltext": 1
                                },
                                load=True)

        self.lpr(self.page)
コード例 #4
0
    def do_next(self, args):

        if not self.page:
            writeln("[-] no results loaded!")
            return
        xpath = engine.Path('//a[@id="pnnext"]/@href')
        n = engine.search(self.page, xpath)

        if not n:
            writeln("[-] no more results!")
            return

        self.page = engine.Page(n[0], load=True)
        self.lpr(self.page)
コード例 #5
0
    def do_visit(self, url):

        url = self.split_positionals(url, "visit")

        if len(url) == 0:
            writeln("usage: visit <url>")
            return

        url = url[0]

        if not self.valid_url(url):
            writeln("invalid url: '{}'".format(url))
            return

        self.page = engine.Page(url, load=True)
        self.lpr(self.page)
コード例 #6
0
    def load_questions(self, page):

        if not self.valid_search(page.url):
            return

        psummary = '//div[@class="summary"]/div[@class="result-link"]'
        xsummary = engine.Path(psummary, link=False)

        plink = "./span/a/@href"
        ptitle = "./span/a/text()"

        ptext = "./span"

        xtitle = engine.Path(ptitle, link=False)
        xlink = engine.Path(plink, link=True)

        results = engine.search(page, xsummary)

        if len(results) == 0:
            writeln("[-] no results found")
            return

        if not isinstance(self.results, Questions):
            self.results = Questions("ERR", [])

        for summary in results:
            page = engine.Page(page.url, tree=summary)

            link = engine.search(page, xlink)
            title = engine.search(page, xtitle)

            if len(link) == 0 or len(title) == 0:
                continue

            link = link[0].strip()
            title = title[0].strip()[3:]

            self.results.questions.append(Question(title, link))
コード例 #7
0
ファイル: bing.py プロジェクト: krornus/misc
    def get_images(self):

        self.page = engine.Page(self.base, params={"q": self.query}, js=True, load=True)
        self.images = self.search_page()

        return self.images