Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
surykatka
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
surykatka
Commits
916e497e
Commit
916e497e
authored
Feb 07, 2020
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reformatted with black
parent
24a1e7d4
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
223 additions
and
28 deletions
+223
-28
src/surykatka/bot.py
src/surykatka/bot.py
+8
-1
src/surykatka/http.py
src/surykatka/http.py
+13
-2
tests/test_http.py
tests/test_http.py
+202
-25
No files found.
src/surykatka/bot.py
View file @
916e497e
...
@@ -144,7 +144,14 @@ class WebBot:
...
@@ -144,7 +144,14 @@ class WebBot:
for
url
in
url_dict
:
for
url
in
url_dict
:
for
ip
in
url_dict
[
url
]:
for
ip
in
url_dict
[
url
]:
checkHttpStatus
(
checkHttpStatus
(
self
.
_db
,
status_id
,
url
,
ip
,
__version__
,
timeout
,
elapsed_fast
,
elapsed_moderate
self
.
_db
,
status_id
,
url
,
ip
,
__version__
,
timeout
,
elapsed_fast
,
elapsed_moderate
,
)
)
# XXX Check location header and check new url recursively
# XXX Check location header and check new url recursively
# XXX Parse HTML, fetch found link, css, js, image
# XXX Parse HTML, fetch found link, css, js, image
...
...
src/surykatka/http.py
View file @
916e497e
...
@@ -133,7 +133,9 @@ def logHttpStatus(db, ip, url, code, total_seconds, fast, moderate, status_id):
...
@@ -133,7 +133,9 @@ def logHttpStatus(db, ip, url, code, total_seconds, fast, moderate, status_id):
(
previous_entry
is
None
)
(
previous_entry
is
None
)
or
(
previous_entry
.
status_code
!=
code
)
or
(
previous_entry
.
status_code
!=
code
)
or
(
or
(
calculateSpeedRange
(
previous_entry
.
total_seconds
,
fast
,
moderate
)
calculateSpeedRange
(
previous_entry
.
total_seconds
,
fast
,
moderate
)
!=
calculateSpeedRange
(
total_seconds
,
fast
,
moderate
)
!=
calculateSpeedRange
(
total_seconds
,
fast
,
moderate
)
)
)
):
):
...
@@ -147,7 +149,16 @@ def logHttpStatus(db, ip, url, code, total_seconds, fast, moderate, status_id):
...
@@ -147,7 +149,16 @@ def logHttpStatus(db, ip, url, code, total_seconds, fast, moderate, status_id):
return
previous_entry
.
status_id
return
previous_entry
.
status_id
def
checkHttpStatus
(
db
,
status_id
,
url
,
ip
,
bot_version
,
timeout
=
TIMEOUT
,
elapsed_fast
=
ELAPSED_FAST
,
elapsed_moderate
=
ELAPSED_MODERATE
):
def
checkHttpStatus
(
db
,
status_id
,
url
,
ip
,
bot_version
,
timeout
=
TIMEOUT
,
elapsed_fast
=
ELAPSED_FAST
,
elapsed_moderate
=
ELAPSED_MODERATE
,
):
parsed_url
=
urlparse
(
url
)
parsed_url
=
urlparse
(
url
)
hostname
=
parsed_url
.
hostname
hostname
=
parsed_url
.
hostname
request_kw
=
{
"timeout"
:
timeout
}
request_kw
=
{
"timeout"
:
timeout
}
...
...
tests/test_http.py
View file @
916e497e
This diff is collapsed.
Click to expand it.
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