createNewBrand.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # coding=utf-8
  2. '''
  3. Created on 2016年3月30日
  4. 这个是为了临时获得新的kind的
  5. @author: ChenHao
  6. '''
  7. from pymongo.mongo_client import MongoClient
  8. import time
  9. from util_common import Constant
  10. TimeStart = time.time()
  11. cli = MongoClient(Constant.MONGODB_URL)
  12. # cli = MongoClient("mongodb://localhost:27017/")
  13. db = cli.spider
  14. '''
  15. 先获得需要将最原始的brand数据清洗一遍
  16. 因为引入了【商标名】
  17. '''
  18. rs = db.propertyvalue_temp.find({"propertyid": "40"}).distinct("value")
  19. for index, r in enumerate(rs):
  20. d = dict()
  21. d["id"] = index + 1
  22. d["nameEn"] = r
  23. d["nameCn"] = r
  24. db.brand_temp.insert_one(d)
  25. #
  26. # detail_analysis_kind = detailAnalysis_kind.DetailAnalysisKind(kindlist)
  27. # cli = MongoClient(Constant.MONGODB_URL)
  28. # db = cli.spider
  29. # rs = db.kind_from_listpage.find({}, {"kindls": True})
  30. # for r in rs:
  31. # detail_analysis_kind._add_into_out_list(r["kindls"])
  32. #
  33. # db.kind_temp_1.insert_many(detail_analysis_kind.out_list)
  34. # print (detail_analysis_kind.out_list)
  35. # print (len(detail_analysis_kind.out_list))
  36. # cli.close()
  37. cli.close()
  38. TimeEnd = time.time()
  39. print ("耗时", TimeEnd - TimeStart)