features = sc.parallelize(data_group[idx]).map(lambda x: (x.host_ip+'^'+x.domain, 1)).reduceByKey(operator.add).map(get_domain_features)

def get_domain_features(x):
    host_url = x[0].split('^')
    host = host_url[0]
    url = host_url[1]
    ext = tldextract.extract(url)
    if ext.domain == "":
        domain = ext.suffix
    else:
        domain = ".".join(ext[1:])

main_tag = domain.split('.')[0]
    num = [i for i in main_tag if i.isdigit()]
    alp = [i for i in main_tag if i.isalpha()]

return (host, (url, domain, main_tag), x[1], len(url), url.count('.') + 1, domain.count('.') + 1, len(main_tag), __Weight(main_tag), __Weight(num), __Weight(alp), main_tag.count('-'))

最新文章

  1. 【C#公共帮助类】 ToolsHelper帮助类
  2. [Cordova] Plugin里使用iOS Framework
  3. Mysql 数据库之修改标的结构
  4. wpf 空白汉字占位符
  5. Python成长笔记 - 基础篇 (三)python列表元组、字典、集合
  6. Oracle必须死之奇怪的ORA-06502错误
  7. ls 知识点
  8. powermockito “mock public 方法内部 Private方法的问题”
  9. Linux下的各种软件安装方法汇总
  10. Android中使用开源框架citypickerview实现省市区三级联动选择
  11. HTML表格表单综合——用户注册表
  12. 通过window.location.search获取页面url传递的参数
  13. Caused by: java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be ope
  14. 我发起了一个 用 C# 写 的 浏览器 开源项目 HtmlCore
  15. Django基础笔记
  16. Asp.Net Core中Json序列化处理整理
  17. awbeci—一个帮助你快速处理日常工作的网址收集网站
  18. [转]Gson的基本使用
  19. 2555: SubString[LCT+SAM]
  20. python练习笔记——计算1/1-1/3+1/5-1/7……的和

热门文章

  1. elasticsearch起步
  2. Currency Exchange(最短路)
  3. PYTHON 源码
  4. (CF)Codeforces445A DZY Loves Chessboard(纯实现题)
  5. 【转】Spring框架深入理解
  6. Android访问网络数据的几种方式Demo
  7. ScSPM
  8. mysql添加删除索引,查看某个表的建表语句
  9. BZOJ 3732 Network 最小瓶颈路
  10. hive cli 启动缓慢问题