Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sp21-cs242-assignment2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
zshan2
sp21-cs242-assignment2
Commits
1f6d908d
Commit
1f6d908d
authored
4 years ago
by
zshan2
Browse files
Options
Downloads
Patches
Plain Diff
try to recover assignment-2.1 branch
parent
0b872741
Branches
assignment-2.1
Branches containing commit
No related tags found
1 merge request
!2
Implementation of assignment-2.2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
API/Functions.py
+4
-0
4 additions, 0 deletions
API/Functions.py
Crawler/Scrape.py
+1
-0
1 addition, 0 deletions
Crawler/Scrape.py
DataBase/JsonParser.py
+1
-0
1 addition, 0 deletions
DataBase/JsonParser.py
with
6 additions
and
0 deletions
API/Functions.py
+
4
−
0
View file @
1f6d908d
...
...
@@ -5,6 +5,7 @@ from dotenv import load_dotenv
def
safe_url
(
query
):
"""
convert query to URL-safe style
"""
load_dotenv
()
host
=
os
.
getenv
(
'
SERVER_HOST
'
)
return
host
+
Parser
.
url_safe
(
query
)
...
...
@@ -24,6 +25,7 @@ def get(query):
def
put
(
query
,
json_file
):
"""
PUT request
"""
print
(
"
PUT:
"
+
query
)
url
=
safe_url
(
query
)
req
=
requests
.
put
(
url
,
json
=
json_file
)
...
...
@@ -32,6 +34,7 @@ def put(query, json_file):
def
post
(
query
,
json_file
):
"""
POST request
"""
print
(
"
POST:
"
+
query
)
url
=
safe_url
(
query
)
req
=
requests
.
post
(
url
,
json
=
json_file
)
...
...
@@ -40,6 +43,7 @@ def post(query, json_file):
def
delete
(
query
):
"""
DELETE request
"""
print
(
"
DELETE:
"
+
query
)
url
=
safe_url
(
query
)
req
=
requests
.
delete
(
url
)
...
...
This diff is collapsed.
Click to expand it.
Crawler/Scrape.py
+
1
−
0
View file @
1f6d908d
...
...
@@ -4,6 +4,7 @@ from DataBase import mongoDB as db
def
scrape_api
(
url_api
,
book_num_api
,
author_num_api
):
"""
Function called by other module to run the scraper
"""
print
(
'
Request received, start scraping
'
)
book_dict_api
=
{}
author_dict_api
=
{}
...
...
This diff is collapsed.
Click to expand it.
DataBase/JsonParser.py
+
1
−
0
View file @
1f6d908d
def
parse_book_dict_to_json
(
dictionary
):
"""
parse books dictionary to json file
"""
item_list
=
list
(
dictionary
.
items
())
return_list
=
[]
for
items
in
item_list
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment