{
+ val response = client.get(url) {
+ header("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15")
+ }
+
+ if (!response.status.isSuccess()) {
+ throw Exception("无法访问文章链接")
+ }
+
+ val html = response.bodyAsText()
+
+ // Extract title
+ val titleRegex = """]*class="[^"]*rich_media_title[^"]*"[^>]*>([\s\S]*?)
""".toRegex()
+ val titleMatch = titleRegex.find(html)
+ val title = titleMatch?.groupValues?.get(1)?.trim()
+ ?.replace(Regex("<[^>]+>"), "")
+ ?.replace(" ", " ")
+ ?.trim()
+ ?: run {
+ // Fallback: try og:title
+ val ogTitleRegex = """]*property="og:title"[^>]*content="([^"]*)"[^>]*>""".toRegex()
+ ogTitleRegex.find(html)?.groupValues?.get(1) ?: "未知标题"
+ }
+
+ // Extract content
+ val contentRegex = """]*class="[^"]*rich_media_content[^"]*"[^>]*id="js_content"[^>]*>([\s\S]*?)
\s*