-
Notifications
You must be signed in to change notification settings - Fork 1
/
jobs.py
37 lines (26 loc) · 1.1 KB
/
jobs.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
import os
import requests
from feed_builder import to_feed
from html_parser import parse_jobs
from telegrapher import create_job_IV_page
from utils import *
BOT_TOKEN = os.environ['BOT_TOKEN']
CHAT_ID = os.environ['CHAT_ID_JOBS']
JOBS_URL = 'https://www.unimi.it/it/studiare/stage-e-lavoro/lavorare-durante-gli-studi/collaborazioni-studentesche/bandi-collaborazioni-studentesche'
JOBS_CHECKLIST_FILE = 'checklist_jobs.dat'
JOBS_FEED_FILE = 'news_jobs.xml'
def main():
jobs_res = requests.get(JOBS_URL)
jobs_entries = parse_jobs(jobs_res.text)
if jobs_entries:
jobs_checklist = load_checklist(JOBS_CHECKLIST_FILE)
for entry in jobs_entries[::-1]:
if not [job for job in jobs_checklist if job.guid == entry.guid]:
entry.iv = create_job_IV_page(entry.link)
jobs_checklist.append(entry)
send_job_message(entry, BOT_TOKEN, CHAT_ID)
save_checklist(jobs_checklist[-50:], JOBS_CHECKLIST_FILE)
jobs_feed = to_feed(jobs_entries, 'jb')
save_feed(jobs_feed, JOBS_FEED_FILE)
if __name__ == '__main__':
main()