终极吉他 API 和终极吉他的用法 api
An ultimate-guitar API and usage of ultimate-api
我在本学期参加的数据库课程中有这个项目,我需要在该课程中构建 Web 应用程序并为其设计数据库。
第一步是收集大量与音乐相关或主题的唱片(至少20k)。现在,我自己是一名吉他手,所以我想用吉他谱 and/or 和弦做点什么,并考虑使用 https://www.ultimate-guitar.com/ 作为谱和和弦的来源。
不幸的是,https://www.ultimate-guitar.com/ 没有提供 API 让我可以轻松访问和检索大量选项卡。对我来说幸运的是,我找到了几个似乎是我需要的 public GitHub 存储库,更重要的是,其中一个在 python 中,这是该项目的首选语言.
遗憾的是,我不熟悉使用外部 API 的方法,我发现自己无法使用上述存储库。我不确定它们是否不完整,或者我是否根本不了解如何操作它们。我尝试使用我的 PyCharm IDE 克隆它们,但无法使用它们来获取标签。
为了避免自己从头开始写东西(这会花费相当多的时间,坦率地说我没有)我有两个选择:
- 向 SO 寻求帮助,了解如何使用这些 API。
- 更改我的项目的主题。
因为这是一个小组项目,所以我想避免第二种选择,所以这是我在 GitHub 上找到的存储库:
- https://github.com/joncardasis/ultimate-api (Python)
- https://github.com/vincepii/uguitar-python (Python)
- https://github.com/masterT/ultimate-guitar-scraper (JavaScript)
我已经向第一个存储库的作者发送了一封电子邮件,因为它是三个存储库中最有前途的,但由于时间限制,我同时发布了这个问题。
更新
按照建议,我将详细说明我的问题,如何使用 ultimate-api 编写一个 python 访问选项卡的客户端程序。
感谢您的建议和指导。
我将回答您提出的一个具体问题:如何使用 ultimate-api
。
首先确保您的计算机上安装了 python3
和 virtualenv
:
$ type -a python3
$ type -a virtualenv
如果这些命令中的任何一个没有 return 您必须执行的任何操作
首先安装给定的程序。现在转到您克隆 ultimate-api
存储库和 运行:
的目录
$ virtualenv -p python3 venv
$ source venv/bin/activate
$ pip install -r requirements.txt
您无需成为 root
用户即可执行此操作。
现在启动服务器:
$ python3 run.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 122-615-257
在您最喜欢的网络浏览器中转到 http://127.0.0.1:5000
,它应该
说 hi
。现在 ultimate-api
的文档说你必须
使用:
A full (including protocol) url for an ultimate-guitar.com tab.
使用 /tab
方法。
示例:
http://127.0.0.1:5000/tab?url=https://tabs.ultimate-guitar.com/tab/_chk_chk_chk/intensify_bass_934215
http://127.0.0.1:5000/tab?url=https://tabs.ultimate-guitar.com/tab/_chk_chk_chk/me_and_giuliani_down_by_the_schoolyard_a_true_story_bass_512135
更新
比如,获取 100 个热门标签的 URL:
$ wget -U firefox https://www.ultimate-guitar.com/top/tabs -O - 2>/dev/null | grep -F 'https://tabs.ultimate-guitar.com/tab/' | grep -E -o '<a href=.+"' | sed -E 's,^<a href=",,' | sed 's,"$,,'
现在您可以将此 URL 用于 ultimate-api
服务器。
我在本学期参加的数据库课程中有这个项目,我需要在该课程中构建 Web 应用程序并为其设计数据库。
第一步是收集大量与音乐相关或主题的唱片(至少20k)。现在,我自己是一名吉他手,所以我想用吉他谱 and/or 和弦做点什么,并考虑使用 https://www.ultimate-guitar.com/ 作为谱和和弦的来源。
不幸的是,https://www.ultimate-guitar.com/ 没有提供 API 让我可以轻松访问和检索大量选项卡。对我来说幸运的是,我找到了几个似乎是我需要的 public GitHub 存储库,更重要的是,其中一个在 python 中,这是该项目的首选语言.
遗憾的是,我不熟悉使用外部 API 的方法,我发现自己无法使用上述存储库。我不确定它们是否不完整,或者我是否根本不了解如何操作它们。我尝试使用我的 PyCharm IDE 克隆它们,但无法使用它们来获取标签。
为了避免自己从头开始写东西(这会花费相当多的时间,坦率地说我没有)我有两个选择:
- 向 SO 寻求帮助,了解如何使用这些 API。
- 更改我的项目的主题。
因为这是一个小组项目,所以我想避免第二种选择,所以这是我在 GitHub 上找到的存储库:
- https://github.com/joncardasis/ultimate-api (Python)
- https://github.com/vincepii/uguitar-python (Python)
- https://github.com/masterT/ultimate-guitar-scraper (JavaScript)
我已经向第一个存储库的作者发送了一封电子邮件,因为它是三个存储库中最有前途的,但由于时间限制,我同时发布了这个问题。
更新
按照建议,我将详细说明我的问题,如何使用 ultimate-api 编写一个 python 访问选项卡的客户端程序。
感谢您的建议和指导。
我将回答您提出的一个具体问题:如何使用 ultimate-api
。
首先确保您的计算机上安装了 python3
和 virtualenv
:
$ type -a python3
$ type -a virtualenv
如果这些命令中的任何一个没有 return 您必须执行的任何操作
首先安装给定的程序。现在转到您克隆 ultimate-api
存储库和 运行:
$ virtualenv -p python3 venv
$ source venv/bin/activate
$ pip install -r requirements.txt
您无需成为 root
用户即可执行此操作。
现在启动服务器:
$ python3 run.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 122-615-257
在您最喜欢的网络浏览器中转到 http://127.0.0.1:5000
,它应该
说 hi
。现在 ultimate-api
的文档说你必须
使用:
A full (including protocol) url for an ultimate-guitar.com tab.
使用 /tab
方法。
示例:
http://127.0.0.1:5000/tab?url=https://tabs.ultimate-guitar.com/tab/_chk_chk_chk/intensify_bass_934215
http://127.0.0.1:5000/tab?url=https://tabs.ultimate-guitar.com/tab/_chk_chk_chk/me_and_giuliani_down_by_the_schoolyard_a_true_story_bass_512135
更新
比如,获取 100 个热门标签的 URL:
$ wget -U firefox https://www.ultimate-guitar.com/top/tabs -O - 2>/dev/null | grep -F 'https://tabs.ultimate-guitar.com/tab/' | grep -E -o '<a href=.+"' | sed -E 's,^<a href=",,' | sed 's,"$,,'
现在您可以将此 URL 用于 ultimate-api
服务器。