mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-19 21:28:26 +02:00
feat: Implement improved search service with supporting models, schemas, and API routers, and refactor site verification script.
This commit is contained in:
1 parent
4720ed6b93
commit
9855040f3e
21 files changed
+57932
-419
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import asyncio
|
||||
import logging
|
||||
from app.services.browserless_service import BrowserlessService
|
||||
from app.core.search_config import SITE_CONFIGS
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
async def dump_site(site_key, query="chaise"):
|
||||
config = SITE_CONFIGS.get(site_key)
|
||||
if not config:
|
||||
logger.error(f"Site {site_key} not found in config")
|
||||
return
|
||||
|
||||
search_url = config["search_url"].format(query=query)
|
||||
logger.info(f"Dumping {site_key} from {search_url}")
|
||||
|
||||
try:
|
||||
content, _ = await BrowserlessService.get_page_content(
|
||||
search_url,
|
||||
wait_selector=config.get("wait_selector"),
|
||||
use_proxy=config.get("requires_proxy", False)
|
||||
)
|
||||
|
||||
if content:
|
||||
filename = f"/app/{site_key}_dump.html"
|
||||
with open(filename, "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
logger.info(f"Successfully dumped to {filename}")
|
||||
else:
|
||||
logger.error(f"Failed to get content for {site_key}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error dumping {site_key}: {e}")
|
||||
|
||||
async def main():
|
||||
await BrowserlessService.initialize()
|
||||
try:
|
||||
await dump_site("amazon.fr")
|
||||
await dump_site("stokomani.fr")
|
||||
# await dump_site("lincroyable.fr") # Already have this
|
||||
finally:
|
||||
await BrowserlessService.shutdown()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in new issue
Block a user