Spaces:
Sleeping
Sleeping
File size: 1,378 Bytes
75d3586 e92b112 75d3586 e92b112 75d3586 e92b112 75d3586 e92b112 75d3586 e92b112 75d3586 e92b112 75d3586 e92b112 75d3586 e92b112 75d3586 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import gradio as gr
from scraper import scrape_amazon_interface
with gr.Blocks(theme="default") as demo:
gr.Markdown(
"<h1 style='text-align: center; color: orange;'>π Amazon.in Scraper</h1>"
"<p style='text-align: center;'>Scrape product details based on your search term!</p>"
)
with gr.Row():
with gr.Column(scale=1):
search_term = gr.Textbox(label="π Search Term", placeholder="e.g., Atta", value="")
pincode = gr.Textbox(label="π Pincode", placeholder="e.g., 400076", value="")
num_pages = gr.Slider(label="π Number of Pages to Scrape", minimum=1, maximum=10, step=1, value=1)
submit_btn = gr.Button("Submit", variant="primary")
clear_btn = gr.Button("Clear", variant="secondary")
with gr.Column(scale=2):
output_file = gr.File(label="β¬οΈ Scraped Excel File Download")
def run_scraper(search_term, pincode, num_pages):
excel_path = scrape_amazon_interface(search_term, pincode, num_pages)
return excel_path
submit_btn.click(
run_scraper,
inputs=[search_term, pincode, num_pages],
outputs=[output_file]
)
clear_btn.click(
lambda: ("", "", 1, None),
inputs=[],
outputs=[search_term, pincode, num_pages, output_file]
)
demo.launch(share=True)
|