コード例 #1
0
def getBestCameraPhone(entities):
    if len(entities) == 0:
        result = CameraPhones.camera("both")
        print(result[0])
        urls = geturls.geturllist(result[0], "amazon")
        resp = uniqueResponses1(
        ) + result[0] + "\nYou can find the best buy link here:\n\n"
        phone_name = result[0]
        phone_name = phone_name.title()
        resp = resp.title()
        urls = "<a href='" + urls[0] + "'>" + phone_name + "</a>"
        resp = resp + urls + getSpecs(phone_name)
        return resp
    elif len(entities) == 1:
        qval = entities[0]["value"]
        if qval == "front":
            result = CameraPhones.camera("front")
            print(result[0])
            urls = geturls.geturllist(result[0], "amazon")
            resp = "Phone with best front camera is " + result[
                0] + "\nYou can find the best buy link here:\n\n"
            phone_name = result[0]
            phone_name = phone_name.title()
            resp = resp.title()
            urls = "<a href='" + urls[0] + "'>" + phone_name + "</a>"
            resp = resp + urls
            return resp
        elif qval == "rear":
            result = CameraPhones.camera("rear")
            print(result[0])
            urls = geturls.geturllist(result[0], "amazon")
            resp = "Phone with the best rear camera is " + result[
                0] + "\nYou can find the best buy link here:\n\n"
            phone_name = result[0]
            phone_name = phone_name.title()
            resp = resp.title()
            urls = "<a href='" + urls[0] + "'>" + phone_name + "</a>"
            resp = resp + urls
            return resp
コード例 #2
0
def ReadAsin(phoneName):
    extracted_data = []
    urllist = url.geturllist(phoneName, "amazon.in")
    print(urllist)
    if len(urllist) == 0:
        print("No amazon url...........................................")
        return ""

    print("GOT AMAZON URL..............................................")
    extracted_data.append(ParseReviews(urllist[0]))
    f = open(Constants.base_file + '\\amazonReviews\\data.json', 'w')
    dump(extracted_data, f, indent=4)
    return extracted_data
    f.close()
コード例 #3
0
 def start_requests(self):
     urllist = urls.geturllist(phone, "")
     for url in urllist:
         yield scrapy.Request(url=url, callback=self.parse)
コード例 #4
0
 def start_requests(self):
     urllist = urls.geturllist(self.phone, "flipkart")
     for url in urllist:
         yield scrapy.Request(url=url, callback=self.logged_in)