__author__ = 'GeoLycosa'

from urllib2 import *

class Fake:
    def Copy_page(self,siteadress):
        if not siteadress[0:7]=='http://':
            siteadress = 'http://' + siteadress

        self.firstSource = urlopen(siteadress).read()

        self.firstSource = self.firstSource.replace('href="//','href="http://')
        self.firstSource = self.firstSource.replace('href="/',('href="' + siteadress + '/'))
        self.firstSource = self.firstSource.replace('src="//','src="http://')
        self.firstSource = self.firstSource.replace('src="/',('src="' + siteadress + '/'))
        self.firstSource = self.firstSource.replace('https','http')

        firstindex = self.firstSource.find('src="')
        while True:
            if not self.firstSource[firstindex+5:firstindex+12] == 'http://':
                self.firstSource = self.firstSource[:firstindex+5] + siteadress + '/' + self.firstSource[firstindex+5:]
            firstindex = firstindex + self.firstSource[firstindex+15:].find('src="') + 15
            if self.firstSource[firstindex:].find('src="') == -1:
                break

        firstindex = self.firstSource.find("src='")
        while True:
            if not self.firstSource[firstindex+5:firstindex+12] == 'http://':
                self.firstSource = self.firstSource[:firstindex+5] + siteadress + '/' + self.firstSource[firstindex+5:]
            firstindex = firstindex + self.firstSource[firstindex+15:].find("src='") + 15
            if self.firstSource[firstindex:].find("src='") == -1:
                break