Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
|
|
|
| 3 |
|
| 4 |
OXYLABS_ENDPOINT = 'https://realtime.oxylabs.io/v1/queries'
|
| 5 |
-
OXYLABS_AUTH = ('
|
| 6 |
|
| 7 |
def get_product_details(asin, domain):
|
| 8 |
payload = {
|
|
@@ -13,7 +14,7 @@ def get_product_details(asin, domain):
|
|
| 13 |
'context': [{'key': 'autoselect_variant', 'value': True}]
|
| 14 |
}
|
| 15 |
response = requests.post(OXYLABS_ENDPOINT, auth=OXYLABS_AUTH, json=payload)
|
| 16 |
-
return response.json()
|
| 17 |
|
| 18 |
def get_reviews(asin, domain):
|
| 19 |
payload = {
|
|
@@ -23,13 +24,13 @@ def get_reviews(asin, domain):
|
|
| 23 |
'parse': True
|
| 24 |
}
|
| 25 |
response = requests.post(OXYLABS_ENDPOINT, auth=OXYLABS_AUTH, json=payload)
|
| 26 |
-
return response.json()
|
| 27 |
|
| 28 |
def amazon_combined_interface(asin, domain):
|
| 29 |
product_details = get_product_details(asin, domain)
|
| 30 |
reviews = get_reviews(asin, domain)
|
| 31 |
|
| 32 |
-
return
|
| 33 |
|
| 34 |
interface = gr.Interface(
|
| 35 |
fn=amazon_combined_interface,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
+
import json
|
| 4 |
|
| 5 |
OXYLABS_ENDPOINT = 'https://realtime.oxylabs.io/v1/queries'
|
| 6 |
+
OXYLABS_AUTH = ('user', 'pass1')
|
| 7 |
|
| 8 |
def get_product_details(asin, domain):
|
| 9 |
payload = {
|
|
|
|
| 14 |
'context': [{'key': 'autoselect_variant', 'value': True}]
|
| 15 |
}
|
| 16 |
response = requests.post(OXYLABS_ENDPOINT, auth=OXYLABS_AUTH, json=payload)
|
| 17 |
+
return json.dumps(response.json(), indent=4)
|
| 18 |
|
| 19 |
def get_reviews(asin, domain):
|
| 20 |
payload = {
|
|
|
|
| 24 |
'parse': True
|
| 25 |
}
|
| 26 |
response = requests.post(OXYLABS_ENDPOINT, auth=OXYLABS_AUTH, json=payload)
|
| 27 |
+
return json.dumps(response.json(), indent=4)
|
| 28 |
|
| 29 |
def amazon_combined_interface(asin, domain):
|
| 30 |
product_details = get_product_details(asin, domain)
|
| 31 |
reviews = get_reviews(asin, domain)
|
| 32 |
|
| 33 |
+
return product_details, reviews
|
| 34 |
|
| 35 |
interface = gr.Interface(
|
| 36 |
fn=amazon_combined_interface,
|