articles/models.py
def download_page(self):
        """
        Download URL of this article and returns the HTML of that page as a string
        """

        # Use the mobile version - the HTML is better-formed
        parsed_url = urlparse(self.url)
        query = dict(parse_qsl(parsed_url.query))
        query["view"] = "mobile"
        url = urlunparse((parsed_url.scheme, parsed_url.netloc, parsed_url.path, parsed_url.params, urlencode(query), ""))

        # Fetch the page
        try:
            r = requests.get(url)
        except RequestException, e:
            raise ValueError("Sorry, I cannot connect to the URL %s" % url)

        if r.status_code != 200:
            raise ValueError("Sorry, I cannot connect to the URL %s, error %s" % (url, r.status_code))

        # If redirect, save redirected
        self.url = r.url
        return r.text

        Download URL of this article and returns the HTML of that page as a string
        
Download URL of this article and returns the HTML of that page as a string
Download URL of this article and returns the HTML of that page as a string
def download_page(self):
        parsed_url = urlparse(self.url)
        query = dict(parse_qsl(parsed_url.query))
        query["view"] = "mobile"
        url = urlunparse((parsed_url.scheme, parsed_url.netloc, parsed_url.path, parsed_url.params, urlencode(query), ""))
        try:
            r = requests.get(url)
        except RequestException, e:
            raise ValueError("Sorry, I cannot connect to the URL %s" % url)
        if r.status_code != 200:
            raise ValueError("Sorry, I cannot connect to the URL %s, error %s" % (url, r.status_code))
        self.url = r.url
        return r.text
def download_page ( self ) : parsed_url = urlparse ( self . url ) query = dict ( parse_qsl ( parsed_url . query ) ) query [ "view" ] = "mobile" url = urlunparse ( ( parsed_url . scheme , parsed_url . netloc , parsed_url . path , parsed_url . params , urlencode ( query ) , "" ) ) try : r = requests . get ( url ) except RequestException , e : raise ValueError ( "Sorry, I cannot connect to the URL %s" % url ) if r . status_code != 200 : raise ValueError ( "Sorry, I cannot connect to the URL %s, error %s" % ( url , r . status_code ) ) self . url = r . url return r . text
Download URL of this article and returns the HTML of that page as a string
Download URL of this article and returns the HTML of that page as a string
"""
        Download URL of this article and returns the HTML of that page as a string
        """ # Use the mobile version - the HTML is better-formed # Fetch the page # If redirect, save redirected
self