mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-15 07:26:51 +00:00
add aisixiang search
This commit is contained in:
27
rsshub/spiders/aisixiang/search.py
Normal file
27
rsshub/spiders/aisixiang/search.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import urllib.parse
|
||||
from rsshub.utils import fetch, DEFAULT_HEADERS
|
||||
|
||||
|
||||
domain = 'https://www.aisixiang.com'
|
||||
|
||||
|
||||
def parse(post):
|
||||
item = {}
|
||||
item['description'] = item['title'] = post.css('a::text').getall()[-1]
|
||||
item['link'] = f"{domain}{post.css('a::attr(href)').getall()[-1]}"
|
||||
item['pubDate'] = post.css('span::text').extract_first()
|
||||
return item
|
||||
|
||||
|
||||
def ctx(category='', keywords=''):
|
||||
keywords_encode = urllib.parse.quote(keywords, encoding='gbk')
|
||||
url = f"{domain}/data/search.php?keyWords={keywords_encode}&searchfield={category}"
|
||||
tree = fetch(url, headers=DEFAULT_HEADERS)
|
||||
posts = tree.css('.search_list').css('li')
|
||||
return {
|
||||
'title': f'{keywords} - {category}搜索 - 爱思想',
|
||||
'link': url,
|
||||
'description': f'{keywords} - {category}搜索 - 爱思想',
|
||||
'author': 'hillerliao',
|
||||
'items': list(map(parse, posts))
|
||||
}
|
||||
Reference in New Issue
Block a user