Skip to content

Commit c8bf5c6

Browse files
authored
Update weixin.rb
1 parent cb5a244 commit c8bf5c6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

websites/weixin.rb

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
uri.scheme = 'https'
1212
URI(uri.to_s)
1313
end
14-
15-
get_with_headers(uri, {})
14+
headers = {
15+
'User-Agent' => 'Mozilla/5.0 (Linux; Android 12; HarmonyOS; FIN-AL60; HMSCore 6.14.0.309; GMSCore 0.3.0.243519) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 HuaweiBrowser/14.0.5.303 Mobile Safari/537.36',
16+
'Referer' => 'https://mp.weixin.qq.com/'
17+
}
18+
get_with_headers(uri, headers)
1619
},
1720
process: -> (html) {
1821
document = Nokogiri::HTML(html)
19-
title = document.css('#activity-name').first.content.strip
20-
author = document.css('#js_name').first.content.strip
21-
content = document.css('#js_content').first
22+
title = document.css('#activity-name').first&.content&.strip || document.css('.rich_media_title').first&.content&.strip || '标题未找到'
23+
author = document.css('#js_name').first&.content&.strip || document.css('.profile_nickname').first&.content&.strip || '作者未找到'
24+
content = document.css('#js_content').first || document.css('.rich_media_content').first
2225

2326
content.traverse{|x|
2427
x.remove_class

0 commit comments

Comments
 (0)