以上每个步骤都会通过Databot框架调用和并发。
BotFrame.render('baiduspider')函数可以用于生产pipe的结构图。需要安装https://www.graphviz.org/download/ 主函数代码:1 def main(): 2 words = ['贸易战', '世界杯'] 3 baidu_url = 'https://www.baidu.com/s?wd=%s' 4 urls = [baidu_url % (word) for word in words] 5 6 7 outputfile=aiofile('baidu.txt') 8 Pipe( 9 Loop(urls), 10 HttpLoader(), 11 Branch(get_all_items,outputfile), 12 Branch(get_all_page_url, HttpLoader(), get_all_items, outputfile), 13 14 ) 15 16 #生成流程图 17 BotFrame.render('baiduspider') 18 BotFrame.run() 19 20 21 main()