当前位置: 首页>>代码示例>>Python>>正文


Python HackerNews.getHomePage方法代码示例

本文整理汇总了Python中hackernews.HackerNews.getHomePage方法的典型用法代码示例。如果您正苦于以下问题:Python HackerNews.getHomePage方法的具体用法?Python HackerNews.getHomePage怎么用?Python HackerNews.getHomePage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hackernews.HackerNews的用法示例。


在下文中一共展示了HackerNews.getHomePage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: refresh

# 需要导入模块: from hackernews import HackerNews [as 别名]
# 或者: from hackernews.HackerNews import getHomePage [as 别名]
    def refresh(self, widget=None, no_timer=False, chrome_data_directory=None, firefox_data_directory=None):

        """Refreshes the menu """
        try:
            # Create an array of 20 false to denote matches in History
            searchResults = [False] * 20
            data = list(reversed(HackerNews.getHomePage()[0:20]))
            urls = [item['url'] for item in data]
            if chrome_data_directory:
                searchResults = self.mergeBoolArray(searchResults, Chrome.search(urls, chrome_data_directory))

            if firefox_data_directory:
                searchResults = self.mergeBoolArray(searchResults, Firefox.search(urls, firefox_data_directory))

            # Remove all the current stories
            for i in self.menu.get_children():
                if hasattr(i, 'url'):
                    self.menu.remove(i)

            # Add back all the refreshed news
            for index, item in enumerate(data):
                item['history'] = searchResults[index]
                if item['url'].startswith('item?id='):
                    item['url'] = "https://news.ycombinator.com/" + item['url']

                self.addItem(item)
        # Catch network errors
        except requests.exceptions.RequestException as e:
            print "[+] There was an error in fetching news items"
        finally:
            # Call every 10 minutes
            if not no_timer:
                gtk.timeout_add(10 * 30 * 1000, self.refresh, widget, no_timer, chrome_data_directory)
开发者ID:artiya4u,项目名称:hackertray,代码行数:35,代码来源:__init__.py

示例2: refresh

# 需要导入模块: from hackernews import HackerNews [as 别名]
# 或者: from hackernews.HackerNews import getHomePage [as 别名]
	def refresh(self, widget=None, data=None):
		data = reversed(HackerNews.getHomePage()[0:20]);
		#Remove all the current stories
		for i in self.menu.get_children():
			if(hasattr(i,'url')):
				self.menu.remove(i)
		#Add back all the refreshed news
		for i in data:
			self.addItem(i)
		#Call every 5 minutes
		gtk.timeout_add(5*60*1000, self.refresh)
开发者ID:gepser,项目名称:hackertray,代码行数:13,代码来源:__init__.py

示例3: refresh

# 需要导入模块: from hackernews import HackerNews [as 别名]
# 或者: from hackernews.HackerNews import getHomePage [as 别名]
    def refresh(self, widget=None, no_timer=False):
        """Refreshes the menu """
        data = reversed(HackerNews.getHomePage()[0:20])

        #Remove all the current stories
        for i in self.menu.get_children():
            if hasattr(i, 'url'):
                self.menu.remove(i)

        #Add back all the refreshed news
        for i in data:
            self.addItem(i)

        #Call every 5 minutes
        if not no_timer:
            gtk.timeout_add(10 * 60 * 1000, self.refresh)
开发者ID:ace03uec,项目名称:hackertray,代码行数:18,代码来源:__init__.py

示例4: runTest

# 需要导入模块: from hackernews import HackerNews [as 别名]
# 或者: from hackernews.HackerNews import getHomePage [as 别名]
	def runTest(self):
		data = HackerNews.getHomePage()
		self.assertTrue(len(data)>0)
开发者ID:Aaron1011,项目名称:hackertray,代码行数:5,代码来源:hn_test.py


注:本文中的hackernews.HackerNews.getHomePage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。