Пример #1
0
def company_data(companies: list):
    company_results = []

    with open('data/raw_companies.json', 'w') as outfile:
        outfile.write('[')
        for company in companies:
            company_serp_params = {
                "q": company.lower(),
                "location": "New York, United States",
                "hl": "en",
                "gl": "us",
                "google_domain": "google.com"
            }

            company_query = GoogleSearchResults(company_serp_params)
            company_query.BACKEND = 'https://serpapi.com/search'
            company_query.SERP_API_KEY = config.API_KEY
            dictionary_results = company_query.get_dictionary()
            company_results.append(dictionary_results)
            print('completed for {}'.format(company))
            time.sleep(5)
            json.dump(dictionary_results, outfile)
            outfile.write(',')
        outfile.write(']')
    return company_results
Пример #2
0
    # loop combines all the possible combinations of key_word & modifier
    for (zipcode,key_word,modifier,device_type) in search_list:
    # TODO: delete [:1] after code is ready
    for zipcode,key_word,modifier,device_type in search_list[:1]:
        serp_params = {
            "q" : key_word + " " + modifier,
            "device" : device_type,
            "location" : "{}, New York, United States".format(str(zipcode)),
            "hl" : "en",
            "gl" : "us",
            "google_domain" : "google.com",
            "google_domain" : "google.com"
        }

        query = GoogleSearchResults(serp_params)
        query.BACKEND = 'http://serpapi.com/search'
        query.SERP_API_KEY = config.API_KEY
        dictionary_results = query.get_dictionary()
        # this will concentrate only on out 4 requirments
        results.append(dictionary_results)
@@ -38,8 +42,8 @@ def _create_search_list(params: params):
    params: its a dict of search list
    """
    # results = []
    prod = product(params.zipcodes, params.key_words, params.modifiers, params.device_types)
    return [prod] 
    prod = product(params["zipcodes"], params["key_words"], params["modifiers"], params["device_types"])
    return [i for i in prod]

# testing how the prodict results shows up
# list(product([1,2,3], [4,5,6], ['as', 'ds', 're','sd'], ['a', 'b']))