Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
crawler
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chengyang Zhong
crawler
Commits
c9429c4d
Commit
c9429c4d
authored
Aug 14, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
0d4db92d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
crawler_week_report.py
tasks/crawler_week_report.py
+6
-7
No files found.
tasks/crawler_week_report.py
View file @
c9429c4d
...
...
@@ -5,6 +5,8 @@
# @author : litao
# coding=utf-8
import
json
import
pymysql
import
xlwt
,
datetime
# from maintenance.func_send_email_with_file import send_file_email
...
...
@@ -47,18 +49,13 @@ sparkConf.set("prod.tidb.database", "jerry_prod")
spark
=
(
SparkSession
.
builder
.
config
(
conf
=
sparkConf
)
.
config
(
"spark.sql.extensions"
,
"org.apache.spark.sql.TiExtensions"
)
.
config
(
"spark.tispark.pd.addresses"
,
"172.16.40.170:2379"
)
.
appName
(
"LR PYSPARK TEST"
)
.
enableHiveSupport
()
.
getOrCreate
())
ti
=
pti
.
TiContext
(
spark
)
ti
.
tidbMapDatabase
(
"jerry_test"
)
spark
.
sql
(
"ADD JAR hdfs:///user/hive/share/lib/udf/brickhouse-0.7.1-SNAPSHOT.jar"
)
spark
.
sql
(
"ADD JAR hdfs:///user/hive/share/lib/udf/hive-udf-1.0-SNAPSHOT.jar"
)
spark
.
sql
(
"CREATE TEMPORARY FUNCTION json_map AS 'brickhouse.udf.json.JsonMapUDF'"
)
spark
.
sql
(
"CREATE TEMPORARY FUNCTION is_json AS 'com.gmei.hive.common.udf.UDFJsonFormatCheck'"
)
spark
.
sql
(
"CREATE TEMPORARY FUNCTION arrayMerge AS 'com.gmei.hive.common.udf.UDFArryMerge'"
)
# user_tag3_portrait_df = connectTi(spark,'user_tag3_portrait')
# user_tag3_portrait_df.createOrReplaceTempView("user_tag3_portrait")
# user_tag3_portrait_df.show(1,False)
es_framework
=
Elasticsearch
(
hosts
=
'172.16.32.37'
,
port
=
9200
)
...
...
@@ -411,13 +408,15 @@ AND page_name in ('search_home','search_home_more','search_home_welfare','search
device_df
.
show
(
1
,
False
)
sql_res
=
device_df
.
collect
()
for
res
in
sql_res
:
print
(
res
,
type
(
res
))
for
single_keyword
in
res
.
query_words
:
res_json
=
json
.
loads
(
res
.
query_words
)
print
(
res_json
,
type
(
res_json
))
for
single_keyword
in
res_json
:
data_count
=
data_dic
.
get
(
single_keyword
)
if
data_count
:
data_dic
[
single_keyword
]
=
data_dic
[
single_keyword
]
+
1
else
:
data_dic
[
single_keyword
]
=
0
print
(
data_dic
)
return
data_dic
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment