试试Scrapegraph-ai
Scrapegraph-ai 是一个基于大型语言模型(LLM)和代理工作流(Agent Workflow)构建的下一代网络爬虫,它利用了前沿的人工智能技术来提高网络数据抓取的效率和准确性。
支持 Groq、Llama3 等模型,Prompt 指挥抓取:这表明 Scrapegraph-ai 支持使用特定的查询语言(如 Groq)和大型语言模型(如 Llama3)来指导爬虫的行为。通过使用 Prompt(提示),用户可以更精确地控制爬虫抓取的内容,这使得爬虫能够更智能地理解和响应用户的需求。
支持 Playwright 处理 JS 渲染的网页:Playwright 是一个用于自动化跨浏览器测试的库,它支持无头模式,并且能够处理 JavaScript 渲染的网页。这意味着 Scrapegraph-ai 可以处理那些依赖于 JavaScript 动态加载内容的复杂网站,这对于传统的静态爬虫来说是一个挑战。
基于 graph builder 与 html、image、speech 节点可以自定义抓取和 parse 逻辑:Scrapegraph-ai 提供了一个图构建器(graph builder),允许用户自定义抓取逻辑。它支持对 HTML、图像和语音等不同类型的数据节点进行抓取和解析。这意味着用户可以根据自己的需求定制爬虫的行为,使其能够从网页中提取特定的数据。
安装
pip install scrapegraphai playwright install示例代码,后端大模型使用了ollama
from scrapegraphai.graphs import SmartScraperGraph
graph_config = {
"llm": {
"model": "ollama/mistral",
"temperature": 0,
"format": "json", # Ollama needs the format to be specified explicitly
"base_url": "http://localhost:11434", # set Ollama URL
},
"embeddings": {
"model": "ollama/nomic-embed-text",
"base_url": "http://localhost:11434", # set Ollama URL
}
}
smart_scraper_graph = SmartScraperGraph(
prompt="List me all the articles",
# also accepts a string with the already downloaded HTML code
source="https://perinim.github.io/projects",
config=graph_config
)
result = smart_scraper_graph.run()
print(result)github:https://github.com/VinciGit00/Scrapegraph-ai
网友回复
go如何写一个类似redis的nosql数据库让python客户端调用?
php7中为啥无法使用$_SERVER['HTTP_RAW_POST_DATA'] ?
chrome插件能否实现2台电脑的远程协助桌面控制?
python如何通过webrtc网页远程协助控制python运行的电脑?
systemd-nspawn与unshare区别?
Firejail、Bubblewrap沙箱与docker、podman容器区别?
如何访问unshare -n -- python3 -m http.server 8000创建的网站url?
linux中如何限制进程执行非法的系统调用命令,例如reboot 删除等等?
pivot_root与chroot有啥区别?
linux中如何限制进程使用cpu、内存、网络的最大值?


