Display the contents of a URL in an IPython notebook.
    
    :param target: the target url.
    :type target: string

    .. seealso:: `iframe_url()` for additional arguments.
195055
def display_iframe_url(target, **kwargs):
    """"""

    txt = iframe_url(target, **kwargs)
    display(HTML(txt))
939920
def get_page_and_url(session, url):
    
    reply = get_reply(session, url)
    return reply.text, reply.url
673708
def _grabContentFromUrl(self, url):
        
        # Defining an empty object for the response
        info = {}
                
        # This part has to be modified...        
        try:            
            # Configuring the socket
            queryURL = "http://" + self.info["host"] + ":" + self.info["port"] + "/" + url
            response = urllib2.urlopen(queryURL)

            # Rebuilding data to be processed
            data = str(response.headers) + "\n"

            data += response.read()

            # Processing data as expected
            info = self._createDataStructure(data)     
            
        # Try to make the errors clear for other users
        except Exception, e:
            errMsg = "ERROR Exception. Something seems to be wrong with the Zeronet Bundler."   
            raise Exception( errMsg + " " + str(e))        
            
        return info
383290
def _initURL(self,
                 org_url,
                 referer_url):
        


        if org_url is not None and org_url != '':
            if not org_url.startswith('http://') and not org_url.startswith('https://'):
                org_url = 'https://' + org_url
            self._org_url = org_url

        if self._org_url.lower().find('/sharing/rest') > -1:
            self._url = self._org_url
        else:
            self._url = self._org_url + "/sharing/rest"

        if self._url.startswith('http://'):
            self._surl = self._url.replace('http://', 'https://')
        else:
            self._surl = self._url

        parsed_url = urlparse(self._org_url)
        self._parsed_org_url = urlunparse((parsed_url[0],parsed_url[1],"","","",""))#added 7/15/2015

        if referer_url is None:
            self._referer_url = parsed_url.netloc
706157
def _execute_search_request(self, url):
        
        try:
            self.request_page = requests.get(url)
        except requests.ConnectionError:
            print("Connection to {0} failed".format(str(url)))
        self.current_html_page = self.request_page.text
        soup = BeautifulSoup(self.current_html_page, "html5lib")
        results = soup.find_all('a', class_=False)
        links = []  # store the final url of search result, 10 links
        # this loop filter the search result links inside the search page
        for target in results:
            # filter only link from search result should be appended
            if target.get('href').find("/url?q") == 0 \
                    and not \
                    target.get('href').find(
                            "/url?q=http://webcache.googleusercontent.com"
                    ) == 0 \
                    and not \
                    target.get('href').find("/url?q=/settings/") == 0:
                start_index = target.get('href').find('http')
                end_index = target.get('href').find('&sa')
                # slice the desired url into ideal link, and append
                # it to reserved list variable
                links.append(target.get('href')[start_index:end_index])
        # this loop inspect if the current page is the final page
        for href in results:
            fnl = 'repeat the search with the omitted results included'
            if href.get_text() == fnl:
                self.is_final_page = True
            else:
                pass
        # send the final url link to class reserved variable
        for link in links:
            self.search_result.append(link)
966392
def open(self, target_uri, **kwargs):
        
        target = urlsplit(target_uri, scheme=self.default_opener)

        opener = self.get_opener(target.scheme)
        query = opener.conform_query(target.query)

        target = opener.get_target(
            target.scheme,
            target.path,
            target.fragment,
            target.username,
            target.password,
            target.hostname,
            target.port,
            query,
            **kwargs
        )
        target.opener_path = target_uri

        return target
714108
def show(self, wid=None, text=None, title=None, url=None, verbose=False):
        

        PARAMS={}
        for p,v in zip(["id","text","title","url"],[wid,text,title,url]):
            if v:
                PARAMS[p]=v

        response=api(url=self.__url+"/show?",PARAMS=PARAMS, method="GET", verbose=verbose)
        return response
23098
def display_listitems(items, url):
    '''
    '''
    if (len(items) == 2 and items[0].get_label() == '..'
        and items[1].get_played()):
        display_video(items)
    else:
        label_width = get_max_len(item.get_label() for item in items)
        num_width = len(str(len(items)))
        output = []
        for i, item in enumerate(items):
            output.append('[%s] %s (%s)' % (
                str(i).rjust(num_width),
                item.get_label().ljust(label_width),
                item.get_path()))

        line_width = get_max_len(output)
        output.append('-' * line_width)

        header = [
            '',
            '=' * line_width,
            'Current URL: %s' % url,
            '-' * line_width,
            '%s %s Path' % ('#'.center(num_width + 2),
                            'Label'.ljust(label_width)),
            '-' * line_width,
        ]
        print '\n'.join(header + output)
1015942
def _link_to(self, page, text=None, title=None, _class="", id="", alt="", **kwargs):
        
        anchor = ""
        if "#" in page:
            page, anchor = page.split("#")
            anchor = "#" + anchor
        meta = self._get_page_meta(page)
        return "<a href='{url}' class='{_class}' id='{id}'  title=\"{title}\">{text}</a>".format(
            url=meta.get("url", "/") + anchor,
            text=text or meta.get("title") or title,
            title=title or "",
            _class=_class,
            id=id
        )
237192
def _initURL(self,
                 org_url,
                 referer_url):
        
        if org_url is not None and org_url != '':
            if not org_url.startswith('http://') and not org_url.startswith('https://'):
                org_url = 'https://' + org_url
            self._org_url = org_url

            if self._org_url.lower().find('/sharing/rest') > -1:
                self._url = self._org_url
            else:
                self._url = self._org_url + "/sharing/rest"

            if self._url.startswith('http://'):
                self._surl = self._url.replace('http://', 'https://')
            else:
                self._surl = self._url

            parsed_url = urlparse(self._org_url)
            self._parsed_org_url = urlunparse((parsed_url[0],parsed_url[1],"","","",""))

        if referer_url is None:
            parsed_org = urlparse(self._org_url)
            self._referer_url = parsed_org.netloc

            url = '{}/portals/self'.format( self._url)

        parameters = {
            'f': 'json'
        }
        portal_info = self._post(url=url,
                                 param_dict=parameters,
                                 securityHandler=self,
                                 proxy_port=self._proxy_port,
                                 proxy_url=self._proxy_url)
        if 'user' in portal_info:
            if 'username' in portal_info['user']:
                self._username = portal_info['user']['username']
594722
def _open_url(self):
        """"""
        load_text = "Loading URL..." if not self.run else "Executing: {}".format(self.run)
        if os.environ.get('BROWSER') not in ['elinks', 'links', 'w3m', 'lynx']:
            self._footer_start_thread(load_text, 5)
250930
def _grabContentFromUrl(self, url):
        
        # Defining an empty object for the response
        response = {}

        # This part has to be modified...        
        try:
            import urllib2

            # Grabbing the data      
            data = urllib2.urlopen(url).read()

            # Processing the data as expectesd
            response = self._createDataStructure(data)        
            
        # Try to make the errors clear for other users
        except Exception, e:
            errMsg = "ERROR. Something happened."   
            raise Exception( errMsg + " " + str(e))
            
        return response
1059162
def open_in_browser(self, session, output_filename=None):
        
        if output_filename is None:
            output_file = tempfile.NamedTemporaryFile(suffix='.html', delete=False)
            output_filename = output_file.name
            with codecs.getwriter('utf-8')(output_file) as f:
                f.write(self.render(session))
        else:
            with codecs.open(output_filename, 'w', 'utf-8') as f:
                f.write(self.render(session))

        from pyinstrument.vendor.six.moves import urllib
        url = urllib.parse.urlunparse(('file', '', output_filename, '', '', ''))
        webbrowser.open(url)
        return output_filename
1277298
def _input_file_as_html_links(cls, session: AppSession):
        ''''''
        scrape_result = session.factory['HTMLScraper'].scrape_file(
            session.args.input_file,
            encoding=session.args.local_encoding or 'utf-8'
        )

        for context in scrape_result.link_contexts:
            yield context.link
64351
def links(self):
        
        if not self._responses:
            return None
        if 'Link' in self._responses[-1].headers:
            links = []
            for l in headers.parse_link(self._responses[-1].headers['Link']):
                link = {'target': l.target}
                link.update({k: v for (k, v) in l.parameters})
                links.append(link)
            return links
735186
def get_page_text(self, page):
        
        url = self.get_page_text_url(page)
        return self._get_url(url)
1360357
def link(self, source, target):
        ''

        return self.operations('link', target.decode(self.encoding),
                                       source.decode(self.encoding))