@sovovs/bycli 2.1.55 → 2.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/clis/tieba/search.js +10 -7
- package/clis/tieba/utils.js +4 -1
- package/package.json +1 -1
package/clis/tieba/search.js
CHANGED
|
@@ -97,13 +97,16 @@ cli({
|
|
|
97
97
|
func: async (page, kwargs) => {
|
|
98
98
|
assertSupportedPage(kwargs);
|
|
99
99
|
const limit = normalizeTiebaLimit(kwargs.limit);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
const searchUrl = getSearchUrl(kwargs);
|
|
101
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
102
|
+
// Tieba occasionally serves an empty shell on the first navigation.
|
|
103
|
+
await page.goto(searchUrl);
|
|
104
|
+
const raw = await page.evaluate(buildExtractSearchResultsEvaluate(limit));
|
|
105
|
+
const items = buildTiebaSearchItems(Array.isArray(raw) ? raw : [], limit);
|
|
106
|
+
if (items.length) {
|
|
107
|
+
return items;
|
|
108
|
+
}
|
|
106
109
|
}
|
|
107
|
-
|
|
110
|
+
throw new EmptyResultError('tieba search', 'Tieba may have blocked the result page, or the DOM structure may have changed');
|
|
108
111
|
},
|
|
109
112
|
});
|
package/clis/tieba/utils.js
CHANGED
|
@@ -78,11 +78,14 @@ function extractTiebaFeedAuthor(feed) {
|
|
|
78
78
|
return '';
|
|
79
79
|
}
|
|
80
80
|
function extractTiebaFeedTitle(feed) {
|
|
81
|
+
const canonicalTitle = normalizeText(feed?.business_info_map?.title);
|
|
82
|
+
if (canonicalTitle)
|
|
83
|
+
return canonicalTitle;
|
|
81
84
|
const title = getTiebaFeedComponent(feed, 'feed_title');
|
|
82
85
|
const titleData = Array.isArray(title.data) ? title.data : [];
|
|
83
86
|
const firstTitle = titleData[0];
|
|
84
87
|
const textInfo = firstTitle?.text_info;
|
|
85
|
-
return normalizeText(textInfo?.text)
|
|
88
|
+
return normalizeText(textInfo?.text);
|
|
86
89
|
}
|
|
87
90
|
function extractTiebaFeedCommentCount(feed) {
|
|
88
91
|
const social = getTiebaFeedComponent(feed, 'feed_social');
|