4lyric 中文文档教程

发布于 5年前 浏览 26 项目主页 更新于 3年前

4Lyrics

一个用于解析和返回来自不同站点的歌词的网络爬虫。 无需 API 密钥!

Benefits (over main branch)

  • Only 3 dependencies.
  • Uses xpath and xmldom instead of Cheerio and its dependencies.
  • Has (hopefully) functional typings for TypeScript users (v2.0.2).
  • Much cleaner and lighter than master branch.
  • Versatile; easily adaptable to other sites.
  • Removed Lyricslive module entirely as the site is now defunct. songlyrics.com is added in place.

Quick-start

const { MusixMatch, AzLyrics, SongLyricsCom, LyricsCom } = require('./lib/musixmatch');
const M = new MusixMatch();
const A = new AzLyrics();
const S = new SongLyricsCom();
const L = new LyricsCom();

(async () => {
    // musixmatch
    const m_u = await M.fetchURLs('Boston more than a feeling');
    const m_l = await M.fetchLyrics(m_u[0]);
    // azlyrics
    const a_u = await A.fetchURLs('Boston more than a feeling');
    const a_l = await A.fetchLyrics(a_u[0]);
    // songlyrics.com
    const s_u = await S.fetchURLs('Boston more than a feeling');
    const s_l = await S.fetchLyrics(s_u[0]);
    // lyrics.com
    const l_u = await L.fetchURLs('Boston more than a feeling');
    const l_l = await L.fetchLyrics(l_u[0]);
})();

Note

  • If no lyrics or URLs are found, an empty array is returned.
  • Musixmatch is recommended for search accuracy and lyric accuracy.

WIP

  1. Options (URL limits, etc.).

4Lyrics

A webscraper to parse and return lyrics from different sites. No API keys required!

Benefits (over main branch)

  • Only 3 dependencies.
  • Uses xpath and xmldom instead of Cheerio and its dependencies.
  • Has (hopefully) functional typings for TypeScript users (v2.0.2).
  • Much cleaner and lighter than master branch.
  • Versatile; easily adaptable to other sites.
  • Removed Lyricslive module entirely as the site is now defunct. songlyrics.com is added in place.

Quick-start

const { MusixMatch, AzLyrics, SongLyricsCom, LyricsCom } = require('./lib/musixmatch');
const M = new MusixMatch();
const A = new AzLyrics();
const S = new SongLyricsCom();
const L = new LyricsCom();

(async () => {
    // musixmatch
    const m_u = await M.fetchURLs('Boston more than a feeling');
    const m_l = await M.fetchLyrics(m_u[0]);
    // azlyrics
    const a_u = await A.fetchURLs('Boston more than a feeling');
    const a_l = await A.fetchLyrics(a_u[0]);
    // songlyrics.com
    const s_u = await S.fetchURLs('Boston more than a feeling');
    const s_l = await S.fetchLyrics(s_u[0]);
    // lyrics.com
    const l_u = await L.fetchURLs('Boston more than a feeling');
    const l_l = await L.fetchLyrics(l_u[0]);
})();

Note

  • If no lyrics or URLs are found, an empty array is returned.
  • Musixmatch is recommended for search accuracy and lyric accuracy.

WIP

  1. Options (URL limits, etc.).
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文