用于从远程数据馈送设置数据处理管道的库
flexes-feed的Python项目详细描述
弯曲进给
用于从Web检索和处理定期更新的数据的通用结构
刮刀使用
要创建一个新的scraper,只需创建一个继承自Scraper
类的类
重写check()
方法。
下面是一个快速的伪示例:
importrequestsfromdata_feed.scraperimportNewFile,ScraperclassMyScraper(Scraper):defcheck(self):response=requests.get(self.channel)# Parse content from page # If the file has changed return a NewFile objectreturn[NewFile(file_url,self.s3_folder)]defrun_scraper():s3_folder='s3://bucket/path/to/store/data'channel='http://somedata.com'scraper=MyScraper(s3_folder,channel)scraper.run()if__name__=='__main__':run_scraper()
请参见examples/noaa_wind_scraper.py以获取实际示例。例子
还要求安装BeautifulSoup4
和lxml
。安装,简单
运行pip install BeautifulSoup4 lxml
。
订户使用情况
要创建新的订阅服务器,只需创建一个继承自Subscriber
的类。
初始化并重写process()
方法。
下面是一个快速的psedoo示例:
fromdata_feed.subscriberimportSubscriberclassMySubscriber(Subscriber):defprocess(self,s3_uri):# Process file(s) in s3_uridefsubscribe():channel='http://somedata.com'sub=MySubscriber(channel)sub.subscribe()if__name__=='__main__':subscribe()
有关使用 Lanlytics API。