#监测
This commit is contained in:
parent
e3f30f9562
commit
ead258943d
|
@ -160,8 +160,9 @@ def register(request):
|
|||
user.is_active = True
|
||||
# user.is_staff = True
|
||||
# user.first_name = phone
|
||||
user.save()
|
||||
|
||||
userprofile = Userprofile(name=name, image=image, user_id=user.id, organization_id=o, sex=sex, status=0)
|
||||
user.save()
|
||||
userprofile.save()
|
||||
messages.success(request, '注册成功,请登录')
|
||||
return HttpResponseRedirect('/')
|
||||
|
|
|
@ -30,32 +30,34 @@ def user_management(request):
|
|||
userpaginator = User.objects.filter(userprofile__organization__province=province,
|
||||
userprofile__organization__cities=cities,
|
||||
userprofile__organization__district=district).order_by('-date_joined')
|
||||
paginator = Paginator(userpaginator, 6)
|
||||
page = int(request.GET.get('page', 1))
|
||||
try:
|
||||
userpaginator = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
userpaginator = paginator.page(1)
|
||||
except EmptyPage:
|
||||
userpaginator = paginator.page(paginator.num_pages)
|
||||
userallinfo = []
|
||||
for u in userpaginator:
|
||||
o = dict()
|
||||
o['id'] = str(u.id)
|
||||
o['image'] = u.userprofile_set.get(user_id=u.id).image
|
||||
o['name'] = u.userprofile_set.get(user_id=u.id).name
|
||||
o['phone'] = u.username
|
||||
o['organization'] = u.userprofile_set.get(user_id=u.id).organization.name
|
||||
o['type'] = u.userprofile_set.get(user_id=u.id).organization.organizationtype.organizationtype
|
||||
organization_id = Userprofile.objects.get(user_id=u.id).organization_id
|
||||
print(organization_id)
|
||||
o['administrativedivision'] = str(str(Organization.objects.get(id=organization_id).province) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).cities) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).district) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).town) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).village)).replace('None', '')
|
||||
userallinfo.append(o)
|
||||
print(userallinfo)
|
||||
if userpaginator is not None:
|
||||
paginator = Paginator(userpaginator, 6)
|
||||
page = int(request.GET.get('page', 1))
|
||||
try:
|
||||
userpaginator = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
userpaginator = paginator.page(1)
|
||||
except EmptyPage:
|
||||
userpaginator = paginator.page(paginator.num_pages)
|
||||
|
||||
for u in userpaginator:
|
||||
o = dict()
|
||||
o['id'] = str(u.id)
|
||||
o['image'] = u.userprofile_set.get(user_id=u.id).image
|
||||
o['name'] = u.userprofile_set.get(user_id=u.id).name
|
||||
o['phone'] = u.username
|
||||
o['organization'] = u.userprofile_set.get(user_id=u.id).organization.name
|
||||
o['type'] = u.userprofile_set.get(user_id=u.id).organization.organizationtype.organizationtype
|
||||
organization_id = Userprofile.objects.get(user_id=u.id).organization_id
|
||||
print(organization_id)
|
||||
o['administrativedivision'] = str(str(Organization.objects.get(id=organization_id).province) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).cities) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).district) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).town) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).village)).replace('None', '')
|
||||
userallinfo.append(o)
|
||||
print(userallinfo)
|
||||
return render(request, 'management/user-management.html',
|
||||
{'userallinfo': userallinfo, 'userpaginator': userpaginator})
|
||||
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
import uuid
|
||||
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class Test(models.Model):
|
||||
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4)
|
||||
title = models.CharField('标题',max_length=256,null=True,blank=True)
|
||||
date = models.CharField('时间',max_length=256,null=True,blank=True)
|
||||
code = models.CharField('公众号',max_length=256,null=True,blank=True)
|
||||
content = models.TextField('正文',null=True,blank=True)
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,365 +1,50 @@
|
|||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>3D动画标签云</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/zzsc-demo.css">
|
||||
<style type="text/css">
|
||||
#tag-cloud {
|
||||
width: 120px;
|
||||
height: 150px;
|
||||
overflow: hidden;
|
||||
/* margin: 50px auto; */
|
||||
}
|
||||
{% extends 'dashboard/base/base.html' %}
|
||||
{% load static %}
|
||||
{% block content %}
|
||||
<body class=" ">
|
||||
<!-- START TOPBAR -->
|
||||
|
||||
#tag-cloud svg {
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
overflow: hidden;
|
||||
}
|
||||
<!-- START CONTAINER -->
|
||||
<div class="page-container row-fluid">
|
||||
|
||||
[class^="icon-"], [class*=" icon-"] {
|
||||
font-family: 'icomoon';
|
||||
speak: none;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
font-variant: normal;
|
||||
text-transform: none;
|
||||
line-height: 1;
|
||||
/* Better Font Rendering =========== */
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
<div class="page-sidebar ">
|
||||
{% include 'dashboard/base/left.html' %}
|
||||
</div>
|
||||
<section id="main-content" class=" ">
|
||||
<section class="wrapper" style='margin-top:60px;display:inline-block;width:100%;padding:15px 0 0 15px;'>
|
||||
{% if messages %}
|
||||
<div class="alert alert-success alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert">
|
||||
<span aria-hidden="true">×</span>
|
||||
<span class="sr-only">Close</span>
|
||||
</button>
|
||||
{% for message in messages %}
|
||||
{{ message }}.<br/>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
body, html {
|
||||
font-size: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
</section>
|
||||
<div class="chatapi-windows "></div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">评论高频词</div>
|
||||
<div class="panel panel-default">
|
||||
<div id="main" style="width: 800px; height: 600px"></div>
|
||||
</div>
|
||||
|
||||
/* Reset */
|
||||
*,
|
||||
*:after,
|
||||
*:before {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
/* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */
|
||||
.clearfix:before,
|
||||
.clearfix:after {
|
||||
content: " ";
|
||||
display: table;
|
||||
}
|
||||
</div>
|
||||
|
||||
.clearfix:after {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
body {
|
||||
/* background: #494A5F; */
|
||||
color: #D5D6E2;
|
||||
font-weight: 500;
|
||||
font-size: 1.05em;
|
||||
font-family: "Microsoft YaHei", "瀹嬩綋", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #2fa0ec;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
a:hover, a:focus {
|
||||
color: #74777b;
|
||||
}
|
||||
|
||||
.zzsc-container {
|
||||
width: 120px;
|
||||
height: 150px;
|
||||
margin: 0 auto;
|
||||
overflow: hidden;
|
||||
background: url(../dun.png) no-repeat;
|
||||
background-size: cover
|
||||
}
|
||||
|
||||
|
||||
/* Header */
|
||||
.zzsc-header {
|
||||
padding: 1em 190px 1em;
|
||||
letter-spacing: -1px;
|
||||
text-align: center;
|
||||
background: #66677c;
|
||||
}
|
||||
|
||||
.zzsc-header h1 {
|
||||
color: #D5D6E2;
|
||||
font-weight: 600;
|
||||
font-size: 2em;
|
||||
line-height: 1;
|
||||
margin-bottom: 0;
|
||||
font-family: "Microsoft YaHei", "瀹嬩綋", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;
|
||||
}
|
||||
|
||||
.zzsc-header h1 span {
|
||||
font-family: "Microsoft YaHei", "瀹嬩綋", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;
|
||||
display: block;
|
||||
font-size: 60%;
|
||||
font-weight: 400;
|
||||
padding: 0.8em 0 0.5em 0;
|
||||
color: #c3c8cd;
|
||||
}
|
||||
|
||||
/*nav*/
|
||||
.zzsc-demo a {
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.zzsc-demo {
|
||||
width: 100%;
|
||||
padding-bottom: 1.2em;
|
||||
}
|
||||
|
||||
.zzsc-demo a {
|
||||
display: inline-block;
|
||||
margin: 0.5em;
|
||||
padding: 0.6em 1em;
|
||||
border: 3px solid #fff;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.zzsc-demo a:hover {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.zzsc-demo a.current {
|
||||
background: #1d7db1;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Top Navigation Style */
|
||||
.zzsc-links {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
white-space: nowrap;
|
||||
font-size: 1.5em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.zzsc-links::after {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
margin-left: -1px;
|
||||
width: 2px;
|
||||
height: 100%;
|
||||
background: #dbdbdb;
|
||||
content: '';
|
||||
-webkit-transform: rotate3d(0, 0, 1, 22.5deg);
|
||||
transform: rotate3d(0, 0, 1, 22.5deg);
|
||||
}
|
||||
|
||||
.zzsc-icon {
|
||||
display: inline-block;
|
||||
margin: 0.5em;
|
||||
padding: 0em 0;
|
||||
width: 1.5em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.zzsc-icon span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.zzsc-icon:before {
|
||||
margin: 0 5px;
|
||||
text-transform: none;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-variant: normal;
|
||||
font-family: 'icomoon';
|
||||
line-height: 1;
|
||||
speak: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* footer */
|
||||
.zzsc-footer {
|
||||
width: 100%;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.zzsc-small {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/****/
|
||||
.related {
|
||||
color: #fff;
|
||||
/* background: #494A5F; */
|
||||
text-align: center;
|
||||
font-size: 1.25em;
|
||||
padding: 0.5em 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.related > a {
|
||||
vertical-align: top;
|
||||
width: calc(100% - 20px);
|
||||
max-width: 340px;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
margin: 20px 10px;
|
||||
padding: 25px;
|
||||
font-family: "Microsoft YaHei", "瀹嬩綋", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;
|
||||
}
|
||||
|
||||
.related a {
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
margin: 20px auto;
|
||||
padding: 10px 20px;
|
||||
opacity: 0.8;
|
||||
-webkit-transition: opacity 0.3s;
|
||||
transition: opacity 0.3s;
|
||||
-webkit-backface-visibility: hidden;
|
||||
}
|
||||
|
||||
.related a:hover,
|
||||
.related a:active {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.related a img {
|
||||
max-width: 100%;
|
||||
opacity: 0.8;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.related a:hover img,
|
||||
.related a:active img {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.related h3 {
|
||||
font-family: "Microsoft YaHei", sans-serif;
|
||||
}
|
||||
|
||||
.related a h3 {
|
||||
font-weight: 300;
|
||||
margin-top: 0.15em;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* icomoon */
|
||||
.icon-zzsc-home-outline:before {
|
||||
content: "\e5000";
|
||||
}
|
||||
|
||||
.icon-zzsc-arrow-forward-outline:before {
|
||||
content: "\e5001";
|
||||
}
|
||||
|
||||
@media screen and (max-width: 50em) {
|
||||
.zzsc-header {
|
||||
padding: 3em 10% 4em;
|
||||
}
|
||||
|
||||
.zzsc-header h1 {
|
||||
font-size: 2em;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 40em) {
|
||||
.zzsc-header h1 {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 30em) {
|
||||
.zzsc-header h1 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="zzsc-container">
|
||||
<div id='tag-cloud'></div>
|
||||
</div>
|
||||
|
||||
<script src="../../../static/js/jquery-1.11.2.min.js" type="text/javascript"></script>
|
||||
<script src="../../static/monitor/js/jquery.svg3dtagcloud.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
var entries = [
|
||||
{label: '1', url: '#', target: '_top'},
|
||||
{label: '2', url: '#', target: '_top'},
|
||||
{label: '3', url: '#', target: '_top'},
|
||||
{label: '4', url: '#', target: '_top'},
|
||||
{label: '5', url: '#', target: '_top'},
|
||||
{label: '6', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: '7', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: '8', url: '#', target: '_top'},
|
||||
{label: '9', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: '10', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'Can I Use', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'URL shortener', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'Grid Layout', url: '#', target: '_top'},
|
||||
{label: 'Twitter', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'deviantART', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'Gulp', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'Browsersync', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'GitHub', url: 'https://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'Shadertoy', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'Tree View', url: '#', target: '_top'},
|
||||
{label: 'jsPerf', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'Foundation', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'CreateJS', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'Velocity.js', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'TweenLite', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'jQuery', url: 'http://www.lanrenzhijia.com/', target: '_top'},
|
||||
{label: 'Notification', url: '#', target: '_top'},
|
||||
{label: 'Parallax', url: '#', target: '_top'}
|
||||
];
|
||||
|
||||
var settings = {
|
||||
entries: entries,
|
||||
width: 500,
|
||||
height: 500,
|
||||
radius: '100%',
|
||||
radiusMin: 75,
|
||||
bgDraw: true,
|
||||
bgColor: 'rgba(0,0,0,0)',
|
||||
opacityOver: 1.00,
|
||||
opacityOut: 0.05,
|
||||
opacitySpeed: 6,
|
||||
fov: 800,
|
||||
speed: 0.2,
|
||||
fontFamily: 'Oswald, Arial, sans-serif',
|
||||
fontSize: '20',
|
||||
fontColor: 'red',
|
||||
fontWeight: 'normal',//bold
|
||||
fontStyle: 'normal',//italic
|
||||
fontStretch: 'normal',//wider, narrower, ultra-condensed, extra-condensed, condensed, semi-condensed, semi-expanded, expanded, extra-expanded, ultra-expanded
|
||||
fontToUpperCase: true
|
||||
};
|
||||
$('#tag-cloud').svg3DTagCloud(settings);
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</section>
|
||||
</div>
|
||||
</body>
|
||||
{% endblock %}
|
||||
{% block add_js %}
|
||||
<script type="text/javascript" src="{% static 'js/echarts.min.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'monitor/js/echarts-wordcloud.min.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'monitor/js/test.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -17,6 +17,22 @@ urlpatterns = [
|
|||
path('sensitive/word/monitoring/',views.sensitive_word_monitoring,name='monitor-sensitive-word-monitoring'),
|
||||
#评论互动监测
|
||||
path('comment/on/interactive/monitoring/',views.comment_on_interactive_monitoring,name='monitor-comment-on-interactive-monitoring'),
|
||||
path('comment/on/interactive/monitoring/json/',views.comment_on_interactive_monitoring_json,name='monitor-comment-on-interactive-monitoring-json'),
|
||||
#监测报告
|
||||
path('monitoring/report/',views.monitoring_report,name='monitor-monitoring-report')
|
||||
path('monitoring/report/',views.monitoring_report,name='monitor-monitoring-report'),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#文章高频词统计
|
||||
path('test/',views.test),
|
||||
path('test/json/',views.test_json)
|
||||
]
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
import csv
|
||||
import json
|
||||
from collections import Counter
|
||||
|
||||
import jieba
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
from dashboard.models import Weixin, Weixin_data, Toutiao_data, Weibo_data, Qita_jc, Group, Toutiao, Weibo, Qita, \
|
||||
Douyin, Douyin_data
|
||||
from monitor.models import Test
|
||||
|
||||
|
||||
def new_media_public_opinion_weixin(request):
|
||||
|
@ -108,5 +115,58 @@ def sensitive_word_monitoring(request):
|
|||
return render(request,'monitor/sensitive-word-monitoring.html')
|
||||
def comment_on_interactive_monitoring(request):
|
||||
return render(request,'monitor/comment-on-interactive-monitoring.html')
|
||||
def comment_on_interactive_monitoring_json(request):
|
||||
data = Test.objects.all()[:500]
|
||||
r = []
|
||||
for d in data:
|
||||
content = d.content
|
||||
r.append(content)
|
||||
# result = jieba.analyse.textrank(content, topK=400, withWeight=True)
|
||||
seg_list = jieba.cut(str(r)) # 对文本进行分词
|
||||
c = Counter()
|
||||
for x in seg_list: # 进行词频统计
|
||||
if len(x) > 1 and x != '\r\n':
|
||||
c[x] += 1
|
||||
res = []
|
||||
for (k, v) in c.most_common(200): # 遍历输出高频词
|
||||
print('%s%s %s %d' % (' ' * (5 - len(k)), k, '*', v))
|
||||
o = dict()
|
||||
o['name'] = k
|
||||
o['value'] = v
|
||||
res.append(o)
|
||||
return HttpResponse(json.dumps({
|
||||
"res":res
|
||||
}))
|
||||
def monitoring_report(request):
|
||||
return render(request,'monitor/monitoring-report.html')
|
||||
|
||||
|
||||
|
||||
def test(request):
|
||||
return render(request,'monitor/test.html')
|
||||
def test_json(request):
|
||||
res = []
|
||||
with open('D:/2020/舆论监测平台/新媒体监测数据/平凉/Result_PL.csv',encoding='utf-8') as csvfile:
|
||||
reader = csv.reader(csvfile)
|
||||
results = []
|
||||
try:
|
||||
for r in reader:
|
||||
print(r[0])
|
||||
results.append(r[5])
|
||||
except:
|
||||
print("777777777777777777777777777777777777777777777777")
|
||||
seg_list = jieba.cut(str(results)) # 对文本进行分词
|
||||
c = Counter()
|
||||
for x in seg_list: # 进行词频统计
|
||||
if len(x) > 1 and x != '\r\n':
|
||||
c[x] += 1
|
||||
for (k, v) in c.most_common(200): # 遍历输出高频词
|
||||
print('%s%s %s %d' % (' ' * (5 - len(k)), k, '*', v))
|
||||
o = dict()
|
||||
o['name'] = k
|
||||
o['value'] = v
|
||||
res.append(o)
|
||||
return HttpResponse(json.dumps({
|
||||
"res": res
|
||||
}))
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import csv
|
||||
import re
|
||||
import uuid
|
||||
import os
|
||||
import psycopg2
|
||||
|
||||
from pip._vendor import chardet
|
||||
|
||||
# G1 = 'host=210.77.68.250 port=5432 dbname=g214_test user=g214 password=g214G214'
|
||||
G2 = 'host=210.77.68.250 port=5432 dbname=newmediaDB1 user=newmedia password=newmedia2020!@#'
|
||||
|
||||
|
||||
def insert_area(title,date, code,content):
|
||||
with psycopg2.connect(G2) as connection:
|
||||
with connection.cursor() as cursor:
|
||||
id = uuid.uuid4()
|
||||
cursor.execute(
|
||||
'insert into monitor_test(id, title,date, code,content) values (%s,%s, %s,%s,%s)'
|
||||
, (str(id),title,date, code,content))
|
||||
connection.commit()
|
||||
return code
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
with open('D:/2020/舆论监测平台/新媒体监测数据/天水/天水20200822-20200922/天水20200822-20200922数据整理/天水微信正文.csv',encoding='utf8') as csvfile:
|
||||
reader = csv.reader(csvfile)
|
||||
try:
|
||||
for r in reader:
|
||||
print(r)
|
||||
title = r[0]
|
||||
date = r[1]
|
||||
code = r[2]
|
||||
content = r[5]
|
||||
insert_area(title, date, code, content)
|
||||
except:
|
||||
pass
|
Loading…
Reference in New Issue