@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.
@@ -97,13 +97,16 @@ cli({
97
97
  func: async (page, kwargs) => {
98
98
  assertSupportedPage(kwargs);
99
99
  const limit = normalizeTiebaLimit(kwargs.limit);
100
- // Use the default browser settle path so we do not read a stale page.
101
- await page.goto(getSearchUrl(kwargs));
102
- const raw = await page.evaluate(buildExtractSearchResultsEvaluate(limit));
103
- const items = buildTiebaSearchItems(Array.isArray(raw) ? raw : [], limit);
104
- if (!items.length) {
105
- throw new EmptyResultError('tieba search', 'Tieba may have blocked the result page, or the DOM structure may have changed');
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
- return items;
110
+ throw new EmptyResultError('tieba search', 'Tieba may have blocked the result page, or the DOM structure may have changed');
108
111
  },
109
112
  });
@@ -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) || normalizeText(feed?.business_info_map?.title);
88
+ return normalizeText(textInfo?.text);
86
89
  }
87
90
  function extractTiebaFeedCommentCount(feed) {
88
91
  const social = getTiebaFeedComponent(feed, 'feed_social');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sovovs/bycli",
3
- "version": "2.1.55",
3
+ "version": "2.1.56",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },