Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
E
esi-table-data
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esi-data-scrapping
esi-table-data
Commits
0488ae61
Commit
0488ae61
authored
Aug 02, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect db from SQL injection
parent
c3c8d3c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
update.py
exa/update.py
+7
-6
No files found.
exa/update.py
View file @
0488ae61
...
@@ -29,8 +29,8 @@ class NewsUpdater:
...
@@ -29,8 +29,8 @@ class NewsUpdater:
tags
.
append
(
i
[
0
])
tags
.
append
(
i
[
0
])
return
json
.
dumps
(
tags
)
return
json
.
dumps
(
tags
)
def
update_news
(
self
,
query
):
def
update_news
(
self
,
query
,
data
):
self
.
db
.
update
(
query
)
self
.
db
.
update
(
query
,
data
)
# this bad way
# this bad way
def
update_all_tags
(
self
):
def
update_all_tags
(
self
):
...
@@ -38,16 +38,17 @@ class NewsUpdater:
...
@@ -38,16 +38,17 @@ class NewsUpdater:
try
:
try
:
text
=
self
.
load_text
(
i
[
1
])
text
=
self
.
load_text
(
i
[
1
])
tags
=
self
.
get_tags
(
text
)
tags
=
self
.
get_tags
(
text
)
self
.
update_news
(
'update wp_esi_news_accept set tags_id="
{}" where id={}'
.
format
(
tags
,
i
[
0
]))
self
.
update_news
(
'update wp_esi_news_accept set tags_id="
%
s" where id=
%
s'
,
(
tags
,
i
[
0
]))
print
(
'News id={} was updated'
.
format
(
i
[
0
]))
print
(
'News id={} was updated'
.
format
(
i
[
0
]))
except
BaseException
as
e
:
except
BaseException
as
e
:
print
(
e
.
with_traceback
())
print
(
e
.
with_traceback
())
def
update_all_text
(
self
):
def
update_all_text
(
self
):
for
i
in
self
.
select_news
(
'select id, url from wp_esi_news_accept
where id>26500
'
):
for
i
in
self
.
select_news
(
'select id, url from wp_esi_news_accept'
):
# try:
# try:
text
=
self
.
load_text
(
i
[
1
])
text
=
self
.
load_text
(
i
[
1
])
self
.
update_news
(
'update wp_esi_news_accept set text="{}" where id={}'
.
format
(
str
(
text
.
encode
(
'ascii'
,
'ignore'
)),
i
[
0
]))
data
=
(
text
.
encode
(
'ascii'
,
'ignore'
),
i
[
0
])
self
.
update_news
(
'update wp_esi_news_accept set text="
%
s" where id=
%
s'
,
data
)
print
(
'News id={} was updated'
.
format
(
i
[
0
]))
print
(
'News id={} was updated'
.
format
(
i
[
0
]))
# except BaseException as e:
# except BaseException as e:
# print(e.with_traceback())
# print(e.with_traceback())
...
@@ -55,4 +56,4 @@ class NewsUpdater:
...
@@ -55,4 +56,4 @@ class NewsUpdater:
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
ml
=
NewsUpdater
()
ml
=
NewsUpdater
()
ml
.
update_all_t
ext
()
ml
.
update_all_t
ags
()
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