From dbfd4ee756a2dd669e40620d5c53c967921e53df Mon Sep 17 00:00:00 2001 From: hillerliao Date: Mon, 23 May 2022 21:45:03 +0800 Subject: [PATCH] select tag class using Containing Text of an Attribute for ph --- rsshub/spiders/producthunt/search.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rsshub/spiders/producthunt/search.py b/rsshub/spiders/producthunt/search.py index 67595c4..d38a5ec 100644 --- a/rsshub/spiders/producthunt/search.py +++ b/rsshub/spiders/producthunt/search.py @@ -8,8 +8,8 @@ domain = 'https://www.producthunt.com' def parse(post): item = {} - item['title'] = post.css('a.styles_title__hxNoA::text').extract_first() - item['description'] = post.css('a.styles_tagline__qrpWc::text').extract_first() + item['title'] = post.css('a[class*="styles_title__"]::text').extract_first() + item['description'] = post.css('a[class*="styles_tagline__"]::text').extract_first() item['link'] = domain + post.css('a::attr(href)').extract_first() return item @@ -19,6 +19,7 @@ def ctx(keyword='', period=''): r_url = f'{domain}' + f'/search?q={keyword}&postedAfter={period}:days' tree = fetch(r_url,headers=DEFAULT_HEADERS) posts = tree.css('.style_layoutMain___pXHk').css('.style_px-mobile-1__DSM5j.style_px-tablet-1__R5dkv.style_pt-mobile-0__lBXpV.style_pt-desktop-6__eNi8V.style_pt-tablet-6__BJU9d.style_pt-widescreen-6__SWPD_.style_pb-mobile-7__OX0Sz.style_pb-desktop-6__EZ3zm.style_pb-tablet-6__F61Qx.style_pb-widescreen-6__UB2pW') + print(posts) items = list(map(parse, posts)) items = [item for item in items if item['title']!=None] return {