-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathscrapper.py
31 lines (23 loc) · 1.12 KB
/
scrapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import requests # python3 -m pip install requests beautifulsoup4
from bs4 import BeautifulSoup
url = "https://www.seek.co.nz/python-jobs?salaryrange=100000-999999&salarytype=annual"
if "__main__" == __name__:
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
def has_data_search(tag):
return tag.has_attr("data-search-sol-meta")
results = soup.find_all(has_data_search)
for job in results:
try:
titleElement = job.find("a", attrs={"data-automation": "jobTitle"})
title = titleElement.get_text()
company = job.find("a", attrs={"data-automation": "jobCompany"}).get_text()
joblink = "https://www.seek.co.nz" + titleElement["href"]
salary = job.find("span", attrs={"data-automation": "jobSalary"})
salary = salary.get_text() if salary else 'n/a'
job = "Titulo: {}\nEmpresa: {}\nSalario: {}\nLink: {}a\n"
job = job.format(title, company, salary, joblink)
print(job)
except Exception as e:
print("Exception: {}".format(e))
pass