这是一个让所有网站都提供API的Python库。以前,我们爬取数据,然后把数据存起来,再创造一个api服务以便其他人可以访问。为此,我们还要定期更新我们的数据。这个库让这一切变得容易起来。你要做的就是定义好你的数据,然后这些数据就会自动地变成可以访问的API。
安装
使用
对于静态站点
-
Item.Meta.route:一个正则表达式,定义API服务的路径。通常情况下,这个路径都会和数据的源站路径保持一致。
-
Item.Meta.source:包含单个数据结构的HTML部分。
-
api.server:运行一个服务器,提供API服务。
-
api.parse:解析路径,如果路径不存在,则返回空。
对于动态站点
需要phantomjs,运行phantomjs -v检查。