import pip import numpy as np import pandas as pd from pandas.io.json import json_normalize # In[6]: pip.main(["install", "yelp3"]) # In[19]: from yelp3.client import Client apikey = 'FGMU22xaV1_98Pwz4dJTmJ9CGiQqQcRVRXFA22B--jnc5GbG6H0fwAXv_NC43G-7vQ3STBQQOljpWpeD776KItOFdeEte5Vj7Ps71Ox2pinPS_tUGTmg80qemx2PWnYx' api = Client(apikey) # In[20]: params = {'term': 'Indian', 'limit': 50, 'offset': 0} val = api.business_search(location='New Jersey', **params) df = json_normalize(val, 'businesses') df2 = json_normalize(val) # In[21]: #pip.main(['install','uszipcode']) from uszipcode import ZipcodeSearchEngine search = ZipcodeSearchEngine() res = search.by_state(state='New Jersey', returns=0)
import numpy as np import pandas as pd from pandas.io.json import json_normalize import pip pip.main(['install', 'yelp3']) from yelp3.client import Client apikey = 'HsoG8rJLtpsvMaQ5_fjUvTSKuFg20fMAzKWWD-4NPSthNeTP3p2yNGSviZ9bmZ0z17vOW1k0Kzpx_FW8qAgSLrHLOYv1kT6Zx9qJUN3jshfcBWy2hcfpQmhk2l-oWnYx' api = Client(apikey) val = api.business_search(location="Newark, NJ") dd = json_normalize(val) dd.head() df = json_normalize(val, 'businesses') df.head() df.columns df[['name', 'rating', 'categories']] df2 = pd.DataFrame(df['categories'].values.tolist(), columns=['cat1', 'cat2', 'cat3']) df2.head() dfcat1 = df2['cat1'].apply(pd.Series) dfcat1 params = {'term': 'sushi', 'limit': 50} val2 = api.business_search(location="Newark, NJ", term='sushi', limit=50) val2 = api.business_search(location="Newark, NJ", **params)
self.assertTrue(resp['total'] >= 0) def test_autocomplete(self): resp = self.client.autocomplete(text="pizz", longitude="40.721769", latitude="-73.993114") self.assertTrue(len(resp['businesses']) >= 0) if __name__ == '__main__': parser = argparse.ArgumentParser("test.py") parser.add_argument("yelp_token", type=str, help="Yelp API access token.") args = parser.parse_args() yelp_token = args.yelp_token client = Client(yelp_token, debug=True) TestYelp.client = client t = TestYelp() suite = unittest.TestSuite() suite.addTest(t) unittest.TextTestRunner(verbosity=2).run(suite)
import numpy as np import pandas as pd from pandas.io.json import json_normalize import pip pip.main(['install', 'yelp3']) from yelp3.client import Client apikey = 'BRfu2UBbZYf-2r2vUVHDOX7C0DWoNgUqfNXioJ_SjwbwUqRYIZ76YuRWc5IWNMKYPO7O9nXQnuzM_lh2mKiYBaE4laA4_GP610DGckhj8BR3Wz2fOo1L0_2LJx2PWnYx' api = Client(apikey) val = api.business_search(location='Charlotte, NC') val dd = json_normalize(val) dd dd.head(5) df = json_normalize(val, 'businesses') df.head() df.columns df[['name', 'rating', 'categories']] df['categories'].values.tolist() df2 = pd.DataFrame(df['categories'].values.tolist(), columns=['cat1', 'cat2', 'cat3']) df2 dfcat1 = df2['cat1'].apply(pd.Series) dfcat1
from yelp3.client import Client app = Flask(__name__) # Time (in s) after which we forget the context for a given user CONTEXT_LIFESPAN = 90 # Load credentials with open("keys.json", "r") as fi: keys = json.load(fi) fb_token = keys["facebook_messenger"]["page_access_token"] # Setup Yelp fusion API client app_id = keys["yelp_fusion"]["app_id"] app_secret = keys["yelp_fusion"]["app_secret"] yelp_client = Client(app_id, app_secret) # Setup Wit API client wit_interface = WitInterface(yelp_client, keys["wit"]["server_side_token"], fb_token) # Setup user_to_current_context dictionary user_to_current_context = defaultdict(dict) user_to_last_message = defaultdict(int) def extract_messages_payload(payload): """Generate dictionaries of input data from the provided payload. """ data = json.loads(payload)
from yelp3.client import Client YELP_ACCESS_TOKEN = "YOUR-ACCESS-TOKEN" client = Client(YELP_ACCESS_TOKEN) resp = client.business_search(location="New York") print(resp)