【发布时间】:2021-04-28 14:18:28
【问题描述】:
我正在尝试从genius.com 获取一些歌词(我知道他们有一个 api。我正在手动进行。)但我似乎每次都没有得到相同的 html 字符串。事实上我把下面的代码放在一个 for 循环,它似乎只在 %50 的时间内工作。
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException;
public class Fetch_lyrics {
public static void testing() {
try {
String urll = "https://genius.com/In-mourning-debris-lyrics";;
Document doc = Jsoup.connect(urll).maxBodySize(0).get();
String text = doc.select("p").first().toString();
System.out.println(text);
} catch (IOException e) {
e.printStackTrace();
}
}
}
我通过 doc 变量打印了原始 html,似乎大约 50% 的时间原始 html 字符串没有包含歌词的 <p> 类(idk,如果它被称为类或其他东西)。谢谢提前。
【问题讨论】: