diff --git a/lib/v2/rsshub/transform/html.js b/lib/v2/rsshub/transform/html.js index c97e62d4a..c4155789e 100644 --- a/lib/v2/rsshub/transform/html.js +++ b/lib/v2/rsshub/transform/html.js @@ -55,10 +55,19 @@ module.exports = async (ctx) => { desc = descEle.html(); } + let pubDate; + const pubDateEle = routeParams.get('itemPubDate') ? item.find(routeParams.get('itemPubDate')) : item; + if (routeParams.get('itemPubDateAttr')) { + pubDate = pubDateEle.attr(routeParams.get('itemPubDateAttr')); + } else { + pubDate = pubDateEle.html(); + } + return { title, link, description: desc, + pubDate }; } catch (e) { return null; diff --git a/lib/v2/rsshub/transform/json.js b/lib/v2/rsshub/transform/json.js index 9ca8d4095..b9857eb71 100644 --- a/lib/v2/rsshub/transform/json.js +++ b/lib/v2/rsshub/transform/json.js @@ -45,6 +45,7 @@ module.exports = async (ctx) => { title: jsonGet(item, routeParams.get('itemTitle')), link, description: routeParams.get('itemDesc') ? jsonGet(item, routeParams.get('itemDesc')) : '', + pubDate: routeParams.get('itemPubDate') ? jsonGet(item, routeParams.get('itemPubDate')) : '', }; }); diff --git a/website/docs/routes/other.md b/website/docs/routes/other.md index 5f7ec11fc..6e7d262ec 100644 --- a/website/docs/routes/other.md +++ b/website/docs/routes/other.md @@ -587,6 +587,8 @@ Specify options (in the format of query string) in parameter `routeParams` param | `itemLinkAttr` | The attributes of `link` element as link | `string` | `href` | | `itemDesc` | The HTML elements as `descrption` in `item` using CSS selector | `string` | `item` element | | `itemDescAttr` | The attributes of `descrption` element as description | `string` | Element html | +| `itemPubDate` | The HTML elements as `pubDate` in `item` using CSS selector | `string` | `item` element | +| `itemPubDateAttr` | The attributes of `pubDate` element as pubDate | `string` | Element html | @@ -616,6 +618,7 @@ Specify options (in the format of query string) in parameter `routeParams` param | `itemTitle` | The JSON Path as `title` in `item` | `string` | None | | `itemLink` | The JSON Path as `link` in `item` | `string` | None | | `itemDesc` | The JSON Path as `description` in `item` | `string` | None | +| `itemPubDate` | The JSON Path as `pubDate` in `item` | `string` | None | :::tip