-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_scraper.py
More file actions
50 lines (41 loc) · 1.48 KB
/
Copy pathtest_scraper.py
File metadata and controls
50 lines (41 loc) · 1.48 KB
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
42
43
44
45
46
47
48
49
50
"""
Test script for the job scraper
"""
import json
import logging
from scraper import JobScraper
from config import DevelopmentConfig
def test_scraper():
"""Test the job scraper with a sample CV text"""
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('test_scraper.log'),
logging.StreamHandler()
]
)
# Sample CV text for testing
cv_text = """
Experienced Python developer with 5 years of experience in web development.
Proficient in Django, Flask, and FastAPI. Strong knowledge of JavaScript,
React, and Node.js. Experience with AWS, Docker, and Kubernetes.
Looking for remote opportunities.
"""
try:
# Initialize scraper with development config
scraper = JobScraper(DevelopmentConfig)
# Get jobs
jobs = scraper.get_jobs(cv_text, language='en')
# Save results to file
with open('test_results.json', 'w', encoding='utf-8') as f:
json.dump(jobs, f, indent=2, ensure_ascii=False)
print(f"\nFound {len(jobs)} jobs")
if jobs:
print("\nSample job:")
print(json.dumps(jobs[0], indent=2, ensure_ascii=False))
except Exception as e:
logging.error(f"Error during testing: {str(e)}", exc_info=True)
if __name__ == '__main__':
test_scraper()