Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -967,41 +967,59 @@ def fetch_yelp_restaurants():
|
|
967 |
|
968 |
return response_text
|
969 |
|
970 |
-
def
|
971 |
params = {
|
972 |
"engine": "google_hotels",
|
973 |
-
"q": "
|
974 |
"check_in_date": "2024-08-14",
|
975 |
"check_out_date": "2024-08-15",
|
976 |
"adults": "2",
|
977 |
"currency": "USD",
|
978 |
"gl": "us",
|
979 |
"hl": "en",
|
980 |
-
"api_key":
|
981 |
}
|
982 |
|
983 |
search = GoogleSearch(params)
|
984 |
results = search.get_dict()
|
985 |
hotels = results.get("organic_results", [])
|
986 |
|
987 |
-
|
988 |
-
|
989 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
990 |
name = hotel.get("title", "No name")
|
991 |
rating = hotel.get("rating", "No rating")
|
992 |
reviews = hotel.get("reviews", "No reviews")
|
993 |
price = hotel.get("price", "No price")
|
994 |
-
location = f"{name}, Birmingham, AL"
|
995 |
link = hotel.get("link", "#")
|
|
|
996 |
|
997 |
-
#
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
|
|
|
|
|
|
|
|
|
|
1003 |
|
1004 |
-
|
|
|
|
|
1005 |
|
1006 |
|
1007 |
|
@@ -1071,6 +1089,8 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
1071 |
news_output = gr.HTML(value=fetch_local_news())
|
1072 |
events_output = gr.HTML(value=fetch_local_events())
|
1073 |
# restaurant_output=gr.HTML(value=fetch_yelp_restaurants())
|
|
|
|
|
1074 |
|
1075 |
|
1076 |
with gr.Column():
|
|
|
967 |
|
968 |
return response_text
|
969 |
|
970 |
+
def fetch_and_display_hotels():
|
971 |
params = {
|
972 |
"engine": "google_hotels",
|
973 |
+
"q": "Bali Resorts",
|
974 |
"check_in_date": "2024-08-14",
|
975 |
"check_out_date": "2024-08-15",
|
976 |
"adults": "2",
|
977 |
"currency": "USD",
|
978 |
"gl": "us",
|
979 |
"hl": "en",
|
980 |
+
"api_key": "74972e6cc9f9e092bd86764a78f7d18c1d71b156eca8b1fe7fd65c2406cfb588"
|
981 |
}
|
982 |
|
983 |
search = GoogleSearch(params)
|
984 |
results = search.get_dict()
|
985 |
hotels = results.get("organic_results", [])
|
986 |
|
987 |
+
# Create an HTML table
|
988 |
+
table_html = """
|
989 |
+
<table style="width:100%; border-collapse: collapse; font-family: Arial, sans-serif;">
|
990 |
+
<tr style="background-color: #f2f2f2;">
|
991 |
+
<th style="padding: 8px; border: 1px solid #ddd;">Name</th>
|
992 |
+
<th style="padding: 8px; border: 1px solid #ddd;">Location</th>
|
993 |
+
<th style="padding: 8px; border: 1px solid #ddd;">Rating</th>
|
994 |
+
<th style="padding: 8px; border: 1px solid #ddd;">Reviews</th>
|
995 |
+
<th style="padding: 8px; border: 1px solid #ddd;">Price</th>
|
996 |
+
<th style="padding: 8px; border: 1px solid #ddd;">Link</th>
|
997 |
+
</tr>
|
998 |
+
"""
|
999 |
+
|
1000 |
+
for hotel in hotels:
|
1001 |
name = hotel.get("title", "No name")
|
1002 |
rating = hotel.get("rating", "No rating")
|
1003 |
reviews = hotel.get("reviews", "No reviews")
|
1004 |
price = hotel.get("price", "No price")
|
|
|
1005 |
link = hotel.get("link", "#")
|
1006 |
+
location = f"{name}, Birmingham, AL"
|
1007 |
|
1008 |
+
# Add each hotel as a row in the table
|
1009 |
+
table_html += f"""
|
1010 |
+
<tr>
|
1011 |
+
<td style="padding: 8px; border: 1px solid #ddd;">{name}</td>
|
1012 |
+
<td style="padding: 8px; border: 1px solid #ddd;">{location}</td>
|
1013 |
+
<td style="padding: 8px; border: 1px solid #ddd;">{rating}</td>
|
1014 |
+
<td style="padding: 8px; border: 1px solid #ddd;">{reviews}</td>
|
1015 |
+
<td style="padding: 8px; border: 1px solid #ddd;">{price}</td>
|
1016 |
+
<td style="padding: 8px; border: 1px solid #ddd;"><a href="{link}" target="_blank">View</a></td>
|
1017 |
+
</tr>
|
1018 |
+
"""
|
1019 |
|
1020 |
+
table_html += "</table>"
|
1021 |
+
|
1022 |
+
return table_html
|
1023 |
|
1024 |
|
1025 |
|
|
|
1089 |
news_output = gr.HTML(value=fetch_local_news())
|
1090 |
events_output = gr.HTML(value=fetch_local_events())
|
1091 |
# restaurant_output=gr.HTML(value=fetch_yelp_restaurants())
|
1092 |
+
gr.Markdown("<h3>Hotel Search Results</h3>")
|
1093 |
+
hotel_output = gr.HTML(value=fetch_and_display_hotels())
|
1094 |
|
1095 |
|
1096 |
with gr.Column():
|