Skip to content

Instantly share code, notes, and snippets.

@rezzzza
Created November 18, 2019 09:19
Show Gist options
  • Save rezzzza/c5b2d642cf879b1cd7f83e327f458c00 to your computer and use it in GitHub Desktop.
Save rezzzza/c5b2d642cf879b1cd7f83e327f458c00 to your computer and use it in GitHub Desktop.
'''
python3 -m venv env
source ./env/bin/activate
pip3 install setuptools bs4 lxml requests
python3 sanjesh.py
'''
from lxml import html
from time import sleep
from os import system
import requests
from bs4 import BeautifulSoup
class Alarm:
def __init__(self):
self.url = 'http://www.sanjesh.org/group.aspx?gid=13'
self.res = self.scrapping()
def scrapping(self):
page = requests.get(self.url)
beautiful_content = self.__bt(page.content)
posts = beautiful_content.find_all('ul')[3] # reading sanjesh post list
return posts.find_all('li')[0].get_text()
@staticmethod
def __bt(content):
return BeautifulSoup(content, 'html.parser')
# It should be the name of last post before what you want!
last_text_before_new_post = "اطلاعيه سازمان سنجش آموزش كشور درباره تاريخ و زمان اعلام نتايج اوليه آزمون ورودي دوره دكتري (Ph.D) نيمه متمركزسال 1398"
while True:
alarm = Alarm()
last_text = alarm.scrapping()
if last_text == last_text_before_new_post:
system('clear')
print("\033[1;31;40m not yet ...")
print(last_text)
sleep(40)
else:
print("\033[1;33;40m *****NEW POST******")
print(last_text)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment