代码拉取完成,页面将自动刷新
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/7/17 18:48
# @Author : Orient
# @File : config.py
# @Software: PyCharm
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/7/16 16:22
# @Author : Orient
# @File : config.py
# @Software: PyCharm
import pymysql
import pymongo
import sys
import traceback
adict = {
"/": "\/",
":": "\:",
"_": "\_",
"、": "\、",
"(": "\(",
")": "\)",
"(": "\(",
")": "\)",
"&": "\&",
"%": "\%",
"%": "\%",
"≥": "\≥",
"=": "\=",
"=": "\=",
"—": "\—",
"-": "\-"
}
#mongo连接信息
MONGODB_CONFIG_CT = {
'host': '114.55.39.144',
'port': 3717,
'db_name': 'original_data',
'username': 'crawler_team',
'password': 'Ur4Q6h2pgA6X4G9h'
}
config_data_center = {
'host': '118.31.118.16',
'port': 3306,
'user': 'dc_select',
'passwd': 'Aenl1pnBtXWpQ5DW',
'db': 'data_center',
'charset': 'utf8'}
def conn_data_center():
conn = pymysql.connect(**config_data_center)
cursor = conn.cursor()
return cursor
#mongo连接
class MongoConnCT(object):
def __init__(self):
# connect db
try:
self.conn = pymongo.MongoClient(MONGODB_CONFIG_CT['host'], MONGODB_CONFIG_CT['port'])
self.db = self.conn[MONGODB_CONFIG_CT['db_name']] # connect db
self.username=MONGODB_CONFIG_CT['username']
self.password=MONGODB_CONFIG_CT['password']
if self.username and self.password:
self.connected = self.db.authenticate(self.username, self.password)
else:
self.connected = True
except Exception:
print(traceback.format_exc())
print('Connect Statics Database Fail.')
sys.exit(1)
if __name__ == '__main__':
pass
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。