Exemplo n.º 1
0
class AmazonHttp:
    """
    Author : nullp01nt3r.

    This soft if for search data on amazon.com. Using http.client and native
    libs. Using this soft is not hacking. Be attentive. If you using
    this soft for hack the site, you bear responsibility for it.
    """

    # TODO: Write metaclass for Http clients.
    def __init__(self, data):
        self.http_domain = "www.amazon.com"
        self.data = data
        self.__http_client = HttpClient(self.http_domain)

    def get_start_page(self):
        response = self.__http_client.get_response("GET", "/", "")
        return self.__get_response(response)

    def get_goods_search(self, page):
        # params = "ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords="
        params = "ref=sr_pg_{p}?rh=i%3Aaps%2Ck%3Atest&page={p}&keywords={data}&ie=UTF8"
        response = self.__http_client.get_response("GET", "/s/" + params.format(p=page, data=self.data), "")
        return self.__get_response(response)

    def get_users_search(self, page):
        params = "ref=cm_wl_search__sortbar_page_{p}?ie=UTF8&field-name={data}&page={p}&submit.search=1"
        response = self.__http_client.get_response("GET", "/gp/registry/search/" + params.format(p=page, data=self.data), "")
        return self.__get_response(response)

    def __get_response(self, response):
        if response.status == OK:
            return response.read()
        else:
            raise ErrorGettingPage(self.http_domain, response.status)
Exemplo n.º 2
0
 def __init__(self, data):
     self.http_domain = "www.amazon.com"
     self.data = data
     self.__http_client = HttpClient(self.http_domain)