def test_url_parse(self): """Testing the url_parse function""" test_url = "http://www.google.com" test_url2 = "http://www.google.com/teste" self.assertEquals(html_utilities.parse_url(""), ["", ""]) self.assertEquals(html_utilities.parse_url(test_url), ["www.google.com", ""]) self.assertEquals(html_utilities.parse_url(test_url2), ["www.google.com", "/teste"])
def get(self): """ Receives the GET request with a URI parameter """ parameter = self.request.get('url') domain = parse_url(parameter)[0] # Including the base javascript for replacing the relative URLs response = html_extractor (parameter) # Adding the decorators functions text_decorator = JsReplaceDecorator(domain, CSSReplaceDecorator(domain)) #script_text = "<script type='text/javascript' src='/javascripts/replacing_urls.js'></script>" #response = response[0:response.find("</head>")] + script_text + response[response.find("</head>"):] self.response.headers['Content-Type'] = 'text/html; charset=UTF-8' self.response.out.write(text_decorator.decorate_text(response))
def get(self): """ Receives the GET request with a URI parameter """ parameter = self.request.get('url') domain = parse_url(parameter)[0] # Including the base javascript for replacing the relative URLs response = html_extractor(parameter) # Adding the decorators functions text_decorator = JsReplaceDecorator(domain, CSSReplaceDecorator(domain)) #script_text = "<script type='text/javascript' src='/javascripts/replacing_urls.js'></script>" #response = response[0:response.find("</head>")] + script_text + response[response.find("</head>"):] self.response.headers['Content-Type'] = 'text/html; charset=UTF-8' self.response.out.write(text_decorator.decorate_text(response))