Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions scraper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ def run():
temp = fetch(exclude)
if not temp:
break
else:
result += temp
exclude += [x["objectID"] for x in temp]
count += 1
result += temp
exclude += [x["objectID"] for x in temp]
count += 1
Comment on lines -27 to +29
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:


logger.info(f"Got {len(result)} new data.")

Expand Down
10 changes: 3 additions & 7 deletions scraper/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ def fetch(filter_object_id=[]):
"requests": [
{
"indexName": "job_postings",
"params": f'query=&hitsPerPage=1000&facetFilters=[["city.work_country_name:Indonesia"]]',
"params": 'query=&hitsPerPage=1000&facetFilters=[["city.work_country_name:Indonesia"]]',
}
]
}

if not filter_object_id:
pass
else:
if filter_object_id:
Comment on lines -17 to +22
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function fetch refactored with the following changes:

# Construct filter to exclude passed objectID
filter = f"&filters=NOT objectID:{filter_object_id[0]}"

Expand All @@ -31,9 +29,7 @@ def fetch(filter_object_id=[]):
data["requests"][0]["params"] += filter

req = requests.post(os.environ["REQUEST_URL"], data=json.dumps(data))
res = req.json()["results"][0]["hits"]

return res
return req.json()["results"][0]["hits"]


def get_job_ids():
Expand Down