This commit is contained in:
xixu-me committed 2024-04-16 22:45:11 +08:00
1 parent 715e052c02
commit 72039ef643
2 files changed
+12 -173

No files matched your search

+12 -2
View File
@@ -7,8 +7,18 @@ import java.util.regex.Matcher;
public class Test {
public static void main(String[] args) {
String regex = "<em class=\"\">(\\d+)</em>.*?<span class=\"title\">(.*?)</span>.*?导演: (.*?)&nbsp;&nbsp;&nbsp;主演: (.*?)<br>.*?(\\d{4})&nbsp;/&nbsp;.*?<span class=\"rating_num\" property=\"v:average\">(.*?)</span>";
String htmlContent = HtmlFetcher.fetchHtmlContent("https://movie.douban.com/top250");
Matcher m = MatcherGetter.getMatcher(regex, htmlContent);
StringBuilder htmlContent = new StringBuilder();
htmlContent.append(HtmlFetcher.fetchHtmlContent("https://movie.douban.com/top250"));
htmlContent.append(HtmlFetcher.fetchHtmlContent("https://movie.douban.com/top250?start=25"));
htmlContent.append(HtmlFetcher.fetchHtmlContent("https://movie.douban.com/top250?start=50"));
htmlContent.append(HtmlFetcher.fetchHtmlContent("https://movie.douban.com/top250?start=75"));
htmlContent.append(HtmlFetcher.fetchHtmlContent("https://movie.douban.com/top250?start=100"));
htmlContent.append(HtmlFetcher.fetchHtmlContent("https://movie.douban.com/top250?start=125"));
htmlContent.append(HtmlFetcher.fetchHtmlContent("https://movie.douban.com/top250?start=150"));
htmlContent.append(HtmlFetcher.fetchHtmlContent("https://movie.douban.com/top250?start=175"));
htmlContent.append(HtmlFetcher.fetchHtmlContent("https://movie.douban.com/top250?start=200"));
htmlContent.append(HtmlFetcher.fetchHtmlContent("https://movie.douban.com/top250?start=225"));
Matcher m = MatcherGetter.getMatcher(regex, htmlContent.toString());
StringBuilder movieInfo = new StringBuilder();
movieInfo.append("豆瓣电影 Top 250\n\n");
while (m.find()) {