Beispiel #1
0
def replace_instyle_links(style_content, request):
    parsed_proxy_url =  urlparse(request.build_absolute_uri())
    image_proxy_url_part = parsed_proxy_url.scheme+'://'+parsed_proxy_url.netloc+'/viewimage/'
    
    for link in re.findall('url\(([^)]+)\)', style_content):
        link = normalize_links(link.replace('"', '').replace("'", ''), request)
        replaced_link = '"'+image_proxy_url_part+link+'"'
        print image_proxy_url_part  
        if style_content.find(replaced_link) == -1:
            style_content = style_content.replace(link, replaced_link)
    
    return style_content
Beispiel #2
0
def replace_instyle_links(style_content, request):
    parsed_proxy_url = urlparse(request.build_absolute_uri())
    image_proxy_url_part = parsed_proxy_url.scheme + '://' + parsed_proxy_url.netloc + '/viewimage/'

    for link in re.findall('url\(([^)]+)\)', style_content):
        link = normalize_links(link.replace('"', '').replace("'", ''), request)
        replaced_link = '"' + image_proxy_url_part + link + '"'
        print image_proxy_url_part
        if style_content.find(replaced_link) == -1:
            style_content = style_content.replace(link, replaced_link)

    return style_content
Beispiel #3
0
def replase_style_links(soup, request):
    parsed_proxy_url = urlparse(request.build_absolute_uri())
    for css_file in soup.findAll('link', {'href': True}):
        css_file[
            'href'] = parsed_proxy_url.scheme + '://' + parsed_proxy_url.netloc + '/viewstyle/' + normalize_links(
                css_file['href'], request)
        print css_file['href']  # debug
    return soup
Beispiel #4
0
def replaced_images_links(soup, request):
	proxy_url_parse = urlparse(request.build_absolute_uri())
	for image in soup.findAll('img',{'src':True}):
		image['src'] = proxy_url_parse.scheme+'://'+proxy_url_parse.netloc+'/viewimage/'+normalize_links(image['src'], request)
	return soup
Beispiel #5
0
def replace_forms(soup, request):
    proxy_url_parse = urlparse(request.build_absolute_uri())
    for form in soup.findAll('form', {'action': True}):
        form[
            'action'] = proxy_url_parse.scheme + '://' + proxy_url_parse.netloc + '/viewpage/' + normalize_links(
                form['action'], request)
    return soup
Beispiel #6
0
def replace_iframes(soup, request):
    proxy_url_parse = urlparse(request.build_absolute_uri())
    for iframe in soup.findAll('iframe', {'src': True}):
        iframe[
            'src'] = proxy_url_parse.scheme + '://' + proxy_url_parse.netloc + '/viewpage/' + normalize_links(
                iframe['src'], request)
    return soup
Beispiel #7
0
def replase_style_links(soup, request):
    parsed_proxy_url =  urlparse(request.build_absolute_uri())
    for css_file in soup.findAll('link',{'href':True}):
        css_file['href'] = parsed_proxy_url.scheme+'://'+parsed_proxy_url.netloc+'/viewstyle/'+normalize_links(css_file['href'], request)
        print css_file['href'] # debug
    return soup
Beispiel #8
0
def replace_scripts(soup, request, is_disable_scripts):
    if is_disable_scripts is True:
        for js in soup.findAll('script'):
            js.extract()
        return soup
    else:
        parse_proxy_url = urlparse(request.build_absolute_uri())
        for js_file in soup.findAll('script', {'src': True}):
            js_file[
                'src'] = parse_proxy_url.scheme + '://' + parse_proxy_url.netloc + '/viewscript/' + normalize_links(
                    js_file['src'], request)
        return soup