ThejasRao commited on
Commit
8af020c
·
verified ·
1 Parent(s): 328fcfe

Update src/agri_predict/scraper.py

Browse files
Files changed (1) hide show
  1. src/agri_predict/scraper.py +4 -3
src/agri_predict/scraper.py CHANGED
@@ -6,6 +6,7 @@ from datetime import datetime, timedelta
6
  from typing import Optional, List, Dict, Any
7
  import logging
8
  from pathlib import Path
 
9
 
10
  # Configure logging
11
  logger = logging.getLogger(__name__)
@@ -29,7 +30,7 @@ class AgmarknetAPIClient:
29
  INCLUDE_EXCEL = "false"
30
 
31
  SCRAPER_API_KEY = "bbbbde6b56c0fde1e2a61c914eb22d14" # <-- Add your key here
32
- SCRAPER_API_URL = "http://api.scraperapi.com"
33
 
34
  TIMEOUT = 30
35
 
@@ -43,7 +44,7 @@ class AgmarknetAPIClient:
43
  f"Records: {records_count} | URL: {url}"
44
  )
45
 
46
- def fetch_data(self, date_str: str):
47
  """Fetch data using ScraperAPI.
48
 
49
  Args:
@@ -76,7 +77,7 @@ class AgmarknetAPIClient:
76
  status_code = response.status_code
77
 
78
  data = response.json()
79
- records_count = len(data.get("data", [])) if isinstance(data, dict) else 0
80
 
81
  self._log_api_call(date_str, original_url, status_code, records_count)
82
 
 
6
  from typing import Optional, List, Dict, Any
7
  import logging
8
  from pathlib import Path
9
+ from urllib.parse import urlencode
10
 
11
  # Configure logging
12
  logger = logging.getLogger(__name__)
 
30
  INCLUDE_EXCEL = "false"
31
 
32
  SCRAPER_API_KEY = "bbbbde6b56c0fde1e2a61c914eb22d14" # <-- Add your key here
33
+ SCRAPER_API_URL = "https://api.scraperapi.com"
34
 
35
  TIMEOUT = 30
36
 
 
44
  f"Records: {records_count} | URL: {url}"
45
  )
46
 
47
+ def fetch_market_data(self, date_str: str):
48
  """Fetch data using ScraperAPI.
49
 
50
  Args:
 
77
  status_code = response.status_code
78
 
79
  data = response.json()
80
+ records_count = self._count_records(data) if isinstance(data, dict) else 0
81
 
82
  self._log_api_call(date_str, original_url, status_code, records_count)
83