Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
url-checker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
url-checker
Commits
c2b9d57d
Commit
c2b9d57d
authored
Oct 16, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prototype storing http status code
parent
b572ffec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
urlchecker_db.py
urlchecker_db.py
+15
-2
urlchecker_http.py
urlchecker_http.py
+3
-4
No files found.
urlchecker_db.py
View file @
c2b9d57d
...
...
@@ -31,7 +31,13 @@ class LogDB:
class
Meta
:
order_by
=
[
"id"
]
class
Query
(
BaseModel
):
ip
=
peewee
.
TextField
()
url
=
peewee
.
TextField
()
status
=
peewee
.
IntegerField
()
self
.
Entry
=
Entry
self
.
Query
=
Query
def
createTables
(
self
):
# http://www.sqlite.org/pragma.html#pragma_user_version
...
...
@@ -40,10 +46,10 @@ class LogDB:
print
(
db_version
)
if
db_version
==
0
:
with
self
.
_db
.
transaction
():
self
.
_db
.
create_tables
([
self
.
Entry
])
self
.
_db
.
create_tables
([
self
.
Entry
,
self
.
Query
])
self
.
_db
.
pragma
(
"user_version"
,
expected_version
)
elif
db_version
!=
expected_version
:
migrator
=
SqliteMigrator
(
self
.
_db
)
#
migrator = SqliteMigrator(self._db)
migration_list
=
[]
sql_query_list
=
[]
...
...
@@ -73,3 +79,10 @@ class LogDB:
id
=
entry
.
id
return
id
def
storeQuery
(
self
,
ip
,
url
,
status
):
with
self
.
_db
.
atomic
():
entry
=
self
.
Query
.
create
(
ip
=
ip
,
url
=
url
,
status
=
status
)
id
=
entry
.
id
return
id
urlchecker_http.py
View file @
c2b9d57d
...
...
@@ -93,8 +93,8 @@ class WebBot:
def
check
(
self
,
url
):
parsed_url
=
urlparse
(
url
)
response
=
self
.
request
(
"GET"
,
url
)
print
(
url
,
response
.
status_code
)
#
response = self.request("GET", url)
#
print(url, response.status_code)
# Get the list of available IPv4 frontend CDN
hostname
=
parsed_url
.
hostname
...
...
@@ -114,8 +114,7 @@ class WebBot:
response
=
self
.
request
(
"GET"
,
url
,
headers
=
{
"Host"
:
hostname
},
session
=
session
)
print
(
ip
,
hostname
,
response
.
status_code
)
self
.
_db
.
storeQuery
(
ip
,
url
,
response
.
status_code
)
def
run
(
self
):
print
(
time
.
strftime
(
"%Y-%m-%d %H:%M:%S"
))
...
...
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