extractAuthor static method
Extract author information
Implementation
static String? extractAuthor(String html) {
final strategies = [
r'<meta[^>]*name=[\"\x27]author[\"\x27][^>]*content=[\"\x27]([^\"\x27]*)[\"\x27]',
r'<[^>]*class=[\"\x27][^\"\x27]*author[^\"\x27]*[\"\x27][^>]*>([^<]*)<',
r'<[^>]*class=[\"\x27][^\"\x27]*byline[^\"\x27]*[\"\x27][^>]*>([^<]*)<',
r'[Bb]y\s+([A-Z][a-z]+\s+[A-Z][a-z]+)',
];
for (final pattern in strategies) {
final match = RegExp(pattern, caseSensitive: false).firstMatch(html);
if (match != null) {
final author = _cleanText(match.group(1) ?? '');
if (author.isNotEmpty) return author;
}
}
return null;
}