Compare commits

..

No commits in common. "9bc7a24f9d1ac91f572cee21cf4f33e046f47172" and "6e0902bcbcb8d67123ba996541b3654429527612" have entirely different histories.

6 changed files with 13 additions and 40 deletions

View file

@ -1,14 +0,0 @@
name: Build
on: [push, pull_request]
jobs:
uv-example:
name: python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: uv build
run: uv build --verbose

6
main.py Normal file
View file

@ -0,0 +1,6 @@
def main():
print("Hello from hardverapro-mcp!")
if __name__ == "__main__":
main()

View file

@ -9,8 +9,3 @@ dependencies = [
"gradio[mcp]>=5.34.2",
"requests>=2.32.4",
]
[tool.setuptools.package-dir]
"scraper" = "src/scraper"
[project.scripts]
run-scraper = "run:main"

16
run.py
View file

@ -1,10 +1,4 @@
import sys
from pathlib import Path
# Add the src directory to Python path
sys.path.append(str(Path(__file__).parent / "src"))
from scraper import categories, search, fetch
import scraper
import gradio as gr
def hardverapro_search(query: str,offset: int = 0, category: str = "All")-> list:
@ -22,7 +16,7 @@ def hardverapro_search(query: str,offset: int = 0, category: str = "All")-> list
- 'price' (str): The price listed
- 'link' (str): A full URL to the listing
"""
raw = search(query,offset=offset,category=category)
raw = scraper.search(query,offset=offset,category=category)
return [[r["title"], r["price"], r["link"]] for r in raw]
def hardverapro_fetch(url: str) -> dict:
@ -38,7 +32,7 @@ def hardverapro_fetch(url: str) -> dict:
- 'description' (str): The description of the listing
- 'img' (str): A full URL to the image
"""
return fetch(url)
return scraper.fetch(url)
@ -47,7 +41,7 @@ iface_search = gr.Interface(
inputs=[
gr.Textbox(label="Search query"),
gr.Number(label="Offset (e.g. 100, 200)", value=0),
gr.Dropdown(choices=categories, value="All"),
gr.Dropdown(choices=scraper.categories, value="All"),
],
outputs=gr.Dataframe(headers=["title", "price", "link"], type="array"),
title="HardverApró Search"
@ -67,6 +61,8 @@ tabbed_interface = gr.TabbedInterface(
def main():
#scraper.fetch("https://hardverapro.hu/apro/sff_2_5_10k_15k_sas_hdd-k_1_2tb-ig/friss.html")
#iface.launch(mcp_server=True)
tabbed_interface.launch(mcp_server=True)
if __name__ == "__main__":

View file

@ -7,7 +7,6 @@ SEARCH_URL="keres.php?stext="
categoriesMap = {
"All": "",
"Hardver": "hardver",
"Alaplap": "hardver/alaplap/",
"Processzor": "hardver/processzor/",
"Memória": "hardver/memoria/",
@ -19,7 +18,6 @@ categoriesMap = {
"Szerver SSD, HDD": "hardver/merevlemez_ssd/szerver_hdd_ssd/",
"Adathordozó": "hardver/adathordozo/",
"Hálózati termékek": "hardver/halozati_termekek/",
"Switch, HUB": "hardver/halozati_termekek/router_switch_repeater/switch_hub/",
"3D nyomtatás": "hardver/3d_nyomtatas/",
"Nyomtató, szkenner": "hardver/nyomtato_szkenner/",
"Játékvezérlő, szimulátor": "hardver/jatekvezerlo/",
@ -92,8 +90,4 @@ def findCategories(url= "https://hardverapro.hu/aprok/hardver/index.html"):
name = a_tag.text.strip()
href = a_tag['href'] if a_tag and a_tag.has_attr('href') else 'No link'
href = href.rsplit('/',1)[0][6:] + '/'
print(f"\"{name}\": \"{href}\",")
# Export it explicitly
__all__ = ['categories', 'search', 'fetch'] # optional, but good practice
print(f"\"{name}\": \"{href}\",")

View file

@ -1,4 +0,0 @@
__version__ = "1.0.0"
from .scraper import categories, search, fetch
__all__ = ["fetch", "search", "categories"]