Add university scraper system with backend, frontend, and configs
- Add src/university_scraper module with scraper, analyzer, and CLI - Add backend FastAPI service with API endpoints and database models - Add frontend React app with university management pages - Add configs for Harvard, Manchester, and UCL universities - Add artifacts with various scraper implementations - Add Docker compose configuration for deployment - Update .gitignore to exclude generated files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
34
backend/app/models/script.py
Normal file
34
backend/app/models/script.py
Normal file
@ -0,0 +1,34 @@
|
||||
"""爬虫脚本模型"""
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Text, ForeignKey, JSON
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from ..database import Base
|
||||
|
||||
|
||||
class ScraperScript(Base):
|
||||
"""爬虫脚本表"""
|
||||
|
||||
__tablename__ = "scraper_scripts"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
university_id = Column(Integer, ForeignKey("universities.id"), nullable=False)
|
||||
|
||||
script_name = Column(String(255), nullable=False)
|
||||
script_content = Column(Text, nullable=False) # Python脚本代码
|
||||
config_content = Column(JSON) # YAML配置转为JSON存储
|
||||
|
||||
version = Column(Integer, default=1)
|
||||
status = Column(String(50), default="draft") # draft, active, deprecated, error
|
||||
error_message = Column(Text)
|
||||
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
# 关联
|
||||
university = relationship("University", back_populates="scripts")
|
||||
jobs = relationship("ScrapeJob", back_populates="script")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ScraperScript(id={self.id}, name='{self.script_name}')>"
|
||||
Reference in New Issue
Block a user