|
| 1 | +import requests |
| 2 | +from bs4 import BeautifulSoup |
| 3 | +import json |
| 4 | +import datetime |
| 5 | +import os |
| 6 | +import re |
| 7 | +import pprint |
| 8 | +pp = pprint.PrettyPrinter(indent=4) |
| 9 | + |
| 10 | + |
| 11 | +class Wisdom: |
| 12 | + def __init__(self,url): |
| 13 | + self.url=url |
| 14 | + self.primaryurl="https://www.wisdomjobs.com/" |
| 15 | + |
| 16 | + def ParsePage(self,url): |
| 17 | + try: |
| 18 | + res = requests.get(url) |
| 19 | + soup = BeautifulSoup(res.content,'lxml') |
| 20 | + return soup |
| 21 | + except Exception as ex: |
| 22 | + return None |
| 23 | + |
| 24 | + def GetAllJobs(self,content): |
| 25 | + jobscontainer = content.findAll('div', {'class': 'jobDiv'}) |
| 26 | + jobslink=[os.path.join(self.primaryurl,j.a['href']) for j in jobscontainer if(j.find('a'))] |
| 27 | + return jobslink |
| 28 | + |
| 29 | + def Run(self): |
| 30 | + jobslinks=self.GetAllJobs(self.ParsePage(self.url)) |
| 31 | + for j in jobslinks: |
| 32 | + content=self.ParsePage(j) |
| 33 | + Cont=content.findAll('table') |
| 34 | + data=self.ParseSinglePage(Cont) |
| 35 | + pp.pprint(data) |
| 36 | + |
| 37 | + def ParseSinglePage(self,Cont): |
| 38 | + try: |
| 39 | + for t in Cont: |
| 40 | + venue=[list(tds.stripped_strings) for tds in t.findAll("span",attrs={'class': 'text-muted'})] |
| 41 | + if (len(venue)==2) and int(re.findall(r'[\d]*',venue[-1][-1])[7])<20: |
| 42 | + Li=t("li") |
| 43 | + datas=[l.text for l in Li] |
| 44 | + jobs={} |
| 45 | + if len(datas)!=0: |
| 46 | + if "Walkin" in datas[0]: |
| 47 | + jobrole=datas[0].split("-")[1:] |
| 48 | + full=" ".join(jobrole).split("|")[0].split("walk in for") |
| 49 | + jobs['title']=full[-1] |
| 50 | + jobs['company']=full[0] |
| 51 | + jobs['exeprince']=datas[1] |
| 52 | + jobs['city']=datas[2] |
| 53 | + jobs['walkindate']=datas[3]+""+datas[4] |
| 54 | + return jobs |
| 55 | + except: |
| 56 | + return None |
| 57 | + |
| 58 | +url='https://www.wisdomjobs.com/latest-walkins' |
| 59 | +w1=Wisdom(url) |
| 60 | +w1.Run() |
| 61 | + |
0 commit comments