Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Samsung Scraper #324

Merged
merged 1 commit into from
Nov 25, 2023
Merged
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
35 changes: 21 additions & 14 deletions sites/samsung.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,57 @@
from scraper_peviitor import Scraper, loadingData
import uuid
import json
from utils import translate_city
from getCounty import get_county

apiUrl = "https://sec.wd3.myworkdayjobs.com/wday/cxs/sec/Samsung_Careers/jobs"
scraper = Scraper()
#Cream un header pentru a putea face request-uri POST
# Cream un header pentru a putea face request-uri POST
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
}

#Cream un dictionar cu datele pe care dorim sa le trimitem catre server
data = {"appliedFacets":{},"limit":20,"offset":0,"searchText":"Romania"}
# Cream un dictionar cu datele pe care dorim sa le trimitem catre server
data = {"appliedFacets": {}, "limit": 20, "offset": 0, "searchText": "Romania"}

#Actualizam header-ul cu datele de mai sus
# Actualizam header-ul cu datele de mai sus
scraper.session.headers.update(headers)

#Facem request-ul POST si salvam numarul total de joburi
# Facem request-ul POST si salvam numarul total de joburi
numberOfJobs = scraper.post(apiUrl, json=data).json().get("total")

#Cream o lista cu numerele de la 0 la numarul total de joburi, cu pasul de 20
# Cream o lista cu numerele de la 0 la numarul total de joburi, cu pasul de 20
iteration = [i for i in range(0, numberOfJobs, 20)]

company = {"company": "Samsung"}
finaljobs = list()

#Pentru fiecare numar din lista, extragem joburile
# Pentru fiecare numar din lista, extragem joburile
for num in iteration:
data["offset"] = num
jobs = scraper.post(apiUrl, json=data).json().get("jobPostings")
for job in jobs:
id = uuid.uuid4()
job_title = job.get("title")
job_link = "https://sec.wd3.myworkdayjobs.com/en-US/Samsung_Careers" + job.get("externalPath")
job_link = "https://sec.wd3.myworkdayjobs.com/en-US/Samsung_Careers" + \
job.get("externalPath")
city = translate_city(
job.get("locationsText").split(",")[1].strip().split(" ")[0]
)
county = get_county(city)
remote = job.get("remoteType")

finaljobs.append({
"id": str(id),
"job_title": job_title,
"job_link": job_link,
"company": company.get("company"),
"country": "Romania",
"city": "Romania"
"city": city,
"county": county,
"remote": remote
})

#afisam numarul total de joburi gasite
print(json.dumps(finaljobs, indent=4))

#se incarca datele in baza de date
loadingData(finaljobs, company.get("company"))
# #se incarca datele in baza de date
# loadingData(finaljobs, company.get("company"))