Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,7 +17,11 @@ from Gradio_UI import GradioUI
|
|
| 17 |
@tool
|
| 18 |
def scrape_drug_reviews_tool(drug_name: str, max_pages: int = 3):
|
| 19 |
"""
|
| 20 |
-
Scrapes Drugs.com
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
"""
|
| 22 |
try:
|
| 23 |
df = asyncio.run(scrape_drugs_com_reviews_playwright(drug_name, max_pages))
|
|
@@ -69,9 +73,9 @@ async def scrape_drugs_com_reviews_playwright(drug_name, max_pages=3, delay=2):
|
|
| 69 |
|
| 70 |
|
| 71 |
all_reviews.append({
|
| 72 |
-
|
| 73 |
-
"review": review_text if review_text else None
|
| 74 |
-
|
| 75 |
})
|
| 76 |
|
| 77 |
await asyncio.sleep(delay)
|
|
|
|
| 17 |
@tool
|
| 18 |
def scrape_drug_reviews_tool(drug_name: str, max_pages: int = 3):
|
| 19 |
"""
|
| 20 |
+
Scrapes reviews from the website Drugs.com using Playwright for a given drug name.
|
| 21 |
+
Args:
|
| 22 |
+
query: the name of the target drug for which I want to retrieve reviews.
|
| 23 |
+
|
| 24 |
+
Output: a dictionary url:review mapping the url of a review to the text of the review
|
| 25 |
"""
|
| 26 |
try:
|
| 27 |
df = asyncio.run(scrape_drugs_com_reviews_playwright(drug_name, max_pages))
|
|
|
|
| 73 |
|
| 74 |
|
| 75 |
all_reviews.append({
|
| 76 |
+
"source": url,
|
| 77 |
+
"review": review_text if review_text else None
|
| 78 |
+
|
| 79 |
})
|
| 80 |
|
| 81 |
await asyncio.sleep(delay)
|