def __init__(self, api, ItemId=None, URL=None):
        self._asin = None
        if ItemId and not URL:
            # check for http://www.amazon.com
            if 'amazon' in ItemId:
                raise ValueError('URL passed as ASIN')

            URL = reviews_url(ItemId)
        elif not URL and not ItemId:
            raise ValueError('Invalid review page parameters. Input a URL or a valid ASIN!')
        elif URL and 'product-reviews' not in URL:  # If product-reviews is in the url it's probably a valid product review page. Let it be.
            # cleanup the url
            URL = reviews_url(extract_reviews_id(URL))

        self.api = api
        self._URL = URL
        self._soup = None
    def reviews_url(self):
        # we could use the asin to directly make a review url
        # but some products actually use the ISBN for the review url
        # and the ASIN version would fail
        # so we'll get the url given to us, and get the asin/isbn from that
        try:
            # the variable has changed in python simple product api, sigh
            item = getattr(self.product, 'item', None)
            if not item:
                item = getattr(self.product, 'parsed_response', None)

            url = unicode(item['CustomerReviews']['IFrameURL'])

            p = urlparse.urlparse(url)
            q = urlparse.parse_qs(p.query)
            asin = q['asin'][0]
        except Exception as e:
            asin = self.asin

        reviews = reviews_url(asin)

        return reviews