Files
ScrapeGraphAI-experiments/app-ollama.py

35 lines
914 B
Python

from scrapegraphai.graphs import SmartScraperGraph
graph_config = {
"llm": {
# "model": "ollama/mistral-nemo:latest",
# "model": "ollama/mistral:latest",
# "model": "ollama/llama3.2:latest",
# "model_tokens": 131072, # ollama show llama3.2:latest
"model": "ollama/qwen2:7b",
"model_tokens": 32768, # ollama show qwen2:7b
"temperature": 0, # 更准确执行任务
"format": "json", # Ollama 需要显式指定格式
},
"embeddings": {
"model": "ollama/nomic-embed-text",
},
"verbose": True,
# "headless": False,
}
# 抓取网页标题
smart_scraper_graph = SmartScraperGraph(
# prompt="List all article titles on the page",
prompt="列出页面上的所有文章标题",
source="https://www.aivi.fyi/",
config=graph_config
)
# Run the pipeline
result = smart_scraper_graph.run()
print(result)