-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathjobguru.py
59 lines (46 loc) · 1.6 KB
/
jobguru.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import json
import time
import traceback
from html import unescape
import requests
from bs4 import BeautifulSoup
def addBlanks(row):
for i in row:
if row[i] is None:
row[i] = ''
elif type(row[i]) is str and i != 'applylink':
row[i] = unescape(row[i].replace('\n', ' ').strip())
def scrape():
timestamp = time.time()
headers = json.load(open('headers.json'))
json_filename = './files/jobguru.json'
fp = open(json_filename, 'w')
url = 'https://www.jobguru.in/jobs_response.php'
response = requests.get(url)
jobs = json.loads(response.text)
jobs = jobs['jobs']
joblist = []
for job in jobs:
row = dict.fromkeys(headers)
row['title'] = [x for x in BeautifulSoup(job['title'], "lxml").stripped_strings][0]
row['applylink'] = 'https://www.jobguru.in/job/' + job['id'] + '/' + job['slug']
row['jd'] = job['description'].lstrip('Job Description')
row['companyname'] = job['company']
row['location'] = job['locations']
row['salary'] = job['salary']
row['type'] = job['shift']
row['startdate'] = job['date']
row['source'] = 'jobguru'
row['experience'] = ''
row['timestamp'] = timestamp
addBlanks(row)
print(row)
joblist.append(row)
json.dump(joblist, fp, indent=1)
fp.close()
try:
scrape()
except Exception as ex:
with open("error.log", 'a') as errorlog:
# print(time.asctime() + ":" + ex, file=errorlog)
traceback.print_exc(file=errorlog)