[weibo] add 'text' option (#8422)

This commit is contained in:
Mike Fährmann
2025-10-19 12:05:27 +02:00
parent 11ccadfd8c
commit f9a8598f35
4 changed files with 61 additions and 1 deletions

View File

@@ -6626,6 +6626,17 @@ Description
will be taken from the original posts, not the retweeted posts.
extractor.weibo.text
--------------------
Type
``bool``
Default
``false``
Description
Extract full ``text`` & ``text_raw`` metadata
for statuses with truncated ``text``.
extractor.weibo.videos
----------------------
Type

View File

@@ -947,6 +947,7 @@
"livephoto": true,
"movies" : false,
"retweets" : false,
"text" : false,
"videos" : true
},
"xfolio":

View File

@@ -34,6 +34,7 @@ class WeiboExtractor(Extractor):
def _init(self):
self.livephoto = self.config("livephoto", True)
self.retweets = self.config("retweets", False)
self.longtext = self.config("text", False)
self.videos = self.config("videos", True)
self.movies = self.config("movies", False)
self.gifs = self.config("gifs", True)
@@ -98,6 +99,10 @@ class WeiboExtractor(Extractor):
files = []
self._extract_status(status, files)
if self.longtext and status.get("isLongText") and \
status["text"].endswith('class="expand">展开</span>'):
status = self._status_by_id(status["id"])
status["date"] = text.parse_datetime(
status["created_at"], "%a %b %d %H:%M:%S %z %Y")
status["count"] = len(files)
@@ -190,7 +195,8 @@ class WeiboExtractor(Extractor):
return video
def _status_by_id(self, status_id):
url = f"{self.root}/ajax/statuses/show?id={status_id}"
url = (f"{self.root}/ajax/statuses/show"
f"?id={status_id}&isGetLongText=true")
return self.request_json(url)
def _user_id(self):

View File

@@ -346,4 +346,46 @@ __tests__ = (
"#log" : "HttpError: '404 ' for 'https://wblive-out.api.weibo.com/2/wblive/room/play?id=1022:2321325216257942356128'",
},
{
"#url" : "https://weibo.com/1893905030/Q9yKt97ID",
"#comment" : "truncated 'text' / 'isLongText: true' (#8422)",
"#class" : weibo.WeiboStatusExtractor,
"#results" : (
"https://wx1.sinaimg.cn/large/70e2b286gy1i6fho7ydx0j20fa08lt8u.jpg",
"https://wx1.sinaimg.cn/large/70e2b286gy1i6fho7zwhmj20u00gvmzg.jpg",
"https://wx4.sinaimg.cn/large/70e2b286gy1i6fho80b47j21u8112wh3.jpg",
),
"status" : {
"id" : 5222785292174627,
"isLongText" : True,
"textLength" : 750,
"text" : """【加快生产速度曝任天堂明年3月生产2500万台<a href="//s.weibo.com/weibo?q=%23Switch2%23" target="_blank">#Switch2#</a>】据彭博社报道,<a href="//s.weibo.com/weibo?q=%23%E4%BB%BB%E5%A4%A9%E5%A0%82%23" target="_blank">#任天堂#</a>已要求供应商在2026年3月底之前生产多达2500万台Switch 2。<br /><br />知情人士透露考虑到今年假期旺季黑色星期五、圣诞节和新年假期以及明年初的持续需求任天堂已要求制造合作伙伴加快生产进度。尽管任天堂计划自2024年底开始组装Switch 2但根据年底购物季的实际需求情况最终产量目标仍有可能进行调整。<br /><br />彭博社分析认为任天堂的出货量很可能轻松超越分析师预测的1760万台甚至超出公司自身更为保守的公开预期。根据组装厂商的发货估算任天堂在本财年截至2026年3月预计将售出约2000万台Switch 2剩余库存则将结转到下一财年。<br /><br />市场研究机构Circana的数据显示美国为任天堂最大市场Switch 2的销售表现比2017年发售的初代Switch高出77%。按照这一趋势,任天堂很可能提前几个月就能超额完成其保守的销售目标。""",
"text_raw" : """\
【加快生产速度曝任天堂明年3月生产2500万台#Switch2#】据彭博社报道,#任天堂#已要求供应商在2026年3月底之前生产多达2500万台Switch 2。
知情人士透露考虑到今年假期旺季黑色星期五、圣诞节和新年假期以及明年初的持续需求任天堂已要求制造合作伙伴加快生产进度。尽管任天堂计划自2024年底开始组装Switch 2但根据年底购物季的实际需求情况最终产量目标仍有可能进行调整。
彭博社分析认为任天堂的出货量很可能轻松超越分析师预测的1760万台甚至超出公司自身更为保守的公开预期。根据组装厂商的发货估算任天堂在本财年截至2026年3月预计将售出约2000万台Switch 2剩余库存则将结转到下一财年。
市场研究机构Circana的数据显示美国为任天堂最大市场Switch 2的销售表现比2017年发售的初代Switch高出77%。按照这一趋势,任天堂很可能提前几个月就能超额完成其保守的销售目标。\
""",
"longText" : {
"created_at" : "Fri Oct 17 17:15:11 +0800 2025",
"mblog_vip_type": 0,
"show_attitude_bar": 0,
"weibo_position": 1,
"content" : """\
【加快生产速度曝任天堂明年3月生产2500万台#Switch2#】据彭博社报道,#任天堂#已要求供应商在2026年3月底之前生产多达2500万台Switch 2。
知情人士透露考虑到今年假期旺季黑色星期五、圣诞节和新年假期以及明年初的持续需求任天堂已要求制造合作伙伴加快生产进度。尽管任天堂计划自2024年底开始组装Switch 2但根据年底购物季的实际需求情况最终产量目标仍有可能进行调整。
彭博社分析认为任天堂的出货量很可能轻松超越分析师预测的1760万台甚至超出公司自身更为保守的公开预期。根据组装厂商的发货估算任天堂在本财年截至2026年3月预计将售出约2000万台Switch 2剩余库存则将结转到下一财年。
市场研究机构Circana的数据显示美国为任天堂最大市场Switch 2的销售表现比2017年发售的初代Switch高出77%。按照这一趋势,任天堂很可能提前几个月就能超额完成其保守的销售目标。\
""",
},
},
},
)