Merge branch 'master' of github.com:hillerliao/RSSHub-python

This commit is contained in:
hillerliao
2022-04-23 22:18:03 +08:00
4 changed files with 51 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
import re
import requests
from rsshub.utils import fetch
from rsshub.utils import DEFAULT_HEADERS
domain = 'https://www.producthunt.com'
def parse(post):
item = {}
item['title'] = post.css('h3 a::text').extract_first()
item['description'] = post.css('.styles_font__m46I_.styles_grey__YlBrh.styles_small__lLD08.styles_normal__FGFK7.styles_tagline__j29pO.styles_lineHeight__kGlRn::text').extract_first()
item['link'] = domain + post.css('a::attr(href)').extract_first()
return item
def ctx(keyword='', period=''):
DEFAULT_HEADERS.update({'Referer': domain})
r_url = f'{domain}' + f'/search?q={keyword}&postedAfter={period}:days'
print(r_url)
tree = fetch(r_url,headers=DEFAULT_HEADERS)
posts = tree.css('.styles_item__Sn_12')
print(posts)
return {
'title': f'{keyword} - Producthunt',
'link': r_url,
'description': f'Producthunt - {r_url}',
'author': 'hillerliao',
'items': list(map(parse, posts))
}

View File

@@ -7,7 +7,7 @@ domain = 'https://www.zaobao.com'
def parse(post):
item = {}
item['description'] = item['title'] = post.css('div.f18.m-eps::text').extract_first()
item['link'] = domain + f"{post.css('a::attr(href)').extract_first()}"
item['link'] = domain + post.css('a::attr(href)').extract_first()
return item
@@ -15,7 +15,7 @@ def ctx(category=''):
url = f"{domain}/realtime/{category}"
tree = fetch(url,headers=DEFAULT_HEADERS)
posts = tree.css('.col-lg-4.col-12.list-block.no-gutters')
print(posts)
# print(posts)
return {
'title': f'{category} - 早报网即时新闻',
'link': url,