本文整理匯總了Python中channel.Channel.articles方法的典型用法代碼示例。如果您正苦於以下問題:Python Channel.articles方法的具體用法?Python Channel.articles怎麽用?Python Channel.articles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類channel.Channel
的用法示例。
在下文中一共展示了Channel.articles方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: parseChannel
# 需要導入模塊: from channel import Channel [as 別名]
# 或者: from channel.Channel import articles [as 別名]
def parseChannel(self, showName):
baseUrl = "http://radio.hrt.hr"
data = self.readUrl(baseUrl + "/emisije/?" + urllib.urlencode({"q": showName.encode("utf-8")}))
urls = re.findall(
r'<div class="col-md-4 col-sm-6 item split">.*?<div class="thumbnail thumbnail-shows">.*?<a href="(.+?)">.*?<img src="(.+?)" alt=".*?" title="(.+?)" class="normal_size">.*?</a>.*?<div class="caption">.*?<h4><a href=".*?">.*?</a></h4>.*?<p>.*?</p>.*?<p>.*?</p>.*?</div>.*?</div>.*?</div>',
data,
re.DOTALL,
)
if not urls:
return None
showLink = baseUrl + urls[0][0]
image = baseUrl + urls[0][1]
title = urls[0][2]
data = self.readUrl(showLink)
searchItems = re.findall(r'<meta name="description" content="(.+?)" />', data, re.DOTALL)
description = searchItems[0]
channel = Channel()
channel.link = showLink.strip()
channel.title = title.strip()
channel.description = description.strip()
channel.image = image.strip()
# channel.lastBuildDate = lastBuildDate.strip()
channel.articles = self.parseArticles(baseUrl, showLink)
return channel