def test_get_html(self):
     client = GoogleSearchResults({
         "q": "Coffee",
         "location": "Austin,Texas"
     })
     data = client.get_html()
     self.assertGreater(len(data), 10)
Beispiel #2
0
def extractPageFromGoogle(companyName):
    params = {
        "q": f"{companyName} ticker symbol",
        "location": "New York, New York, United States",
        "hl": "en",
        "gl": "us",
        "google_domain": "google.com",
        "api_key":
        "ea8844b4b82278532aaf2ef9d64d254cf0db59150b7e3b8e7d09752eccdfffcb",
        "output": "html",
        "device": "desktop",
    }

    client = GoogleSearchResults(params)
    #results = [client.get_html(), client.get_json()]
    results = client.get_html()

    return results
Beispiel #3
0
def extractTickerFromGoogle(companyName):
    params = {
        "q": f" \"{companyName}\" + \"ticker symbol\" ",
        "location": "New York, New York, United States",
        "hl": "en",
        "gl": "us",
        "google_domain": "google.com",
        "api_key":
        "9b66566f114d4a876cb052f3ff8d5ef682bf76424fdab1928f45433f1cf5f06d",
        "output": "html",
        "device": "desktop",
    }

    client = GoogleSearchResults(params)
    results = client.get_html()

    try:
        found = re.search('<span class=\"HfMth\">(.+?)</span>',
                          results).group(1)
    except AttributeError:
        # AAA, ZZZ not found in the original string
        found = ''

    return found