12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- # -*- coding: utf-8 -*-
- # !/usr/bin/env python
- import os, sys,time,datetime
- import urllib, urllib2, sys
- import requests
- from mongoengine import register_connection, PointField, DynamicDocument, StringField
- import simplejson as json
- import ssl
- import xlrd
- from xlrd import xldate_as_tuple
- from collections import OrderedDict
- PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
- sys.path.insert(0, PROJECT_ROOT)
- os.environ.setdefault("DJANGO_SETTINGS_MODULE", "configs.testing")
- from script.base import init_env
- init_env(interactive = False)
- from apps.web.core.db import Searchable
- from apps.web.core.utils import generate_excel_report
- register_connection(alias = 'spider',
- name = 'spider',
- host = '211.159.224.10',
- port = 27119,
- username = 'service',
- password = 'oOzjoQcO5DyyiN97AY0NpzJ6vztjNpx5',
- authentication_source = 'admin')
- class ChargeStation(Searchable):
- province = StringField(default = "")
- city = StringField(default = "")
- name = StringField(default = '')
- address = StringField(default = '')
- telephone = StringField(default = '')
- lat = StringField(default = '')
- lng = StringField(default = '')
- more = StringField(default = '')
-
- meta = {
- 'collection': 'ChargeStation',
- 'db_alias': 'spider',
- 'unique_together': {'lat', 'lng'}
- }
- records = []
- for info in ChargeStation.objects.all():
- dataList = [
- (u'province', info.province),
- (u'city', info.city),
- (u'name', info.name),
- (u'address', info.address),
- (u'telephone', info.telephone),
- (u'more', info.more),
- ]
- records.append(OrderedDict(dataList))
- generate_excel_report('F:/baiduGaodeStation.xlsx', records,True)
- print('OK')
|