【慕課網實戰】Spark Streaming實時流處理項目實戰筆記十五之銘文升級版
阿新 • • 發佈:2018-02-01
spa for 序列 html art mat div pre paths
銘文一級:[木有筆記]
銘文二級:
第12章 Spark Streaming項目實戰
行為日誌分析:
1.訪問量的統計
2.網站黏性
3.推薦
Python實時產生數據
訪問URL->IP信息->referer和狀態碼->日誌訪問時間->寫入到文件中
本地與虛擬機都要裝了python才能運行
重要代碼:
#coding=UTF-8
#數組最後一個沒有“,”
url_paths = [ "class/128.html", "class/112.html", "class/143.html", "class/141.html", "learn/821", "course/list" ] #增強for循環 #sample(seq, n) 從序列seq中選擇n個隨機且獨立的元素; return ".".join([str(item) for item in slice]) def sample_url() return random.sample(url_paths,1)[0] query_log = "{url}".format(url=sample_url())
一張圖讓你學會Python基礎語法(看不清可另存為):
http://blog.csdn.net/qq_30845505/article/details/51588423
【慕課網實戰】Spark Streaming實時流處理項目實戰筆記十五之銘文升級版