Conversation
jackwener
left a comment
There was a problem hiding this comment.
Review
Good feature direction — stock ranking data from Sina Finance is useful. A few issues need fixing before merge:
1. Security: String interpolation injection in evaluate
const marketType = '${market}';User input is directly interpolated into the evaluate string. Use JSON.stringify:
const marketType = ${JSON.stringify(market)};2. Missing market validation
Add choices to the arg definition to restrict valid values:
{ name: 'market', type: 'string', default: 'cn', choices: ['cn', 'hk', 'us', 'wh', 'ft'], help: '...' }3. Column names inconsistent with other sinafinance commands
Other commands use lowercase (title, date, url). This PR uses PascalCase (Column, Name, Price). Please use lowercase: rank, name, symbol, market, price, change, url.
4. Unrelated change in rolling-news.ts
The ?from=opencli URL tracking change is unrelated to stock-rank and modifies existing output. Please remove it from this PR.
5. Null safety on tabEl
const tabEl = document.querySelector('[data-type="' + marketType + '"]');
const marketName = tabEl.textContent; // tabEl may be nullUse optional chaining: tabEl?.textContent || marketType
6. Add navigateBefore: false
The func already calls page.goto(), so the framework's pre-navigation is redundant. Add navigateBefore: false to avoid double navigation.
- Fix string interpolation injection: use JSON.stringify for market param - Add choices validation for market arg (cn/hk/us/wh/ft) - Normalize column names to lowercase (rank/name/symbol/market/price/change/url) - Add navigateBefore: false to avoid redundant navigation - Add null safety on tabEl with optional chaining - Remove unused waitForElement helper and unnecessary await on querySelectorAll - Remove unrelated ?from=opencli tracking change from rolling-news.ts - Remove ?from=opencli tracking from stock-rank URLs
jackwener
left a comment
There was a problem hiding this comment.
All review issues fixed. LGTM.
* 增加新浪财经热搜股票榜 * fix: address review issues in stock-rank adapter - Fix string interpolation injection: use JSON.stringify for market param - Add choices validation for market arg (cn/hk/us/wh/ft) - Normalize column names to lowercase (rank/name/symbol/market/price/change/url) - Add navigateBefore: false to avoid redundant navigation - Add null safety on tabEl with optional chaining - Remove unused waitForElement helper and unnecessary await on querySelectorAll - Remove unrelated ?from=opencli tracking change from rolling-news.ts - Remove ?from=opencli tracking from stock-rank URLs --------- Co-authored-by: jackwener <jakevingoo@gmail.com>
Description
Add
sinafinance stock-rankcommand - 新浪财经热搜榜新增
stock-rank命令,支持抓取新浪财经移动端首页股票热搜榜数据:同时更新了
docs/adapters/browser/sinafinance.md文档。Type of Change
Checklist
docs/adapters/(updated existing sinafinance.md)--marketflag for market selection)Screenshots / Output