| |
| import os, tempfile, pandas as pd, streamlit as st |
| from scraper import scrape_tender_list |
|
|
| |
| os.environ["STREAMLIT_BROWSER_GATHERUSAGESTATS"] = "false" |
|
|
| st.set_page_config(page_title="TenderDetail Scraper", layout="wide") |
| st.title("📝 TenderDetail List‑Page Scraper") |
|
|
| with st.expander("ℹ️ Instructions", expanded=True): |
| st.markdown( |
| """ |
| 1. Copy any Tenderdetail **list page URL** |
| (e.g. <https://www.tenderdetail.com/Indian-tender/uadd-tenders>). |
| 2. Paste it below and click **Scrape**. |
| 3. Preview the table, then download it as Excel. |
| """ |
| ) |
|
|
| url = st.text_input("Tenderdetail list URL", value="https://www.tenderdetail.com/Indian-tender/uadd-tenders") |
|
|
| if st.button("🔍 Scrape"): |
| if not url.strip(): |
| st.error("Please enter a valid URL.") |
| st.stop() |
|
|
| with st.spinner("Fetching & parsing…"): |
| try: |
| df = scrape_tender_list(url) |
| except Exception as e: |
| st.error(f"Scrape failed: {e}") |
| st.stop() |
|
|
| st.success(f"Found **{len(df)}** tenders.") |
| st.dataframe(df, use_container_width=True) |
|
|
| |
| tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") |
| df.to_excel(tmp.name, index=False) |
| with open(tmp.name, "rb") as f: |
| st.download_button( |
| "⬇️ Download Excel", |
| f, |
| file_name="tender_list.xlsx", |
| mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" |
| ) |
|
|
|
|