import requests
import time
from bs4 import BeautifulSoup
from notifypy import Notify

def get_info (url):
    page = requests.get(url)
    soup = BeautifulSoup(page.content,"html.parser")
    opCells = soup.find_all("div",class_="opCell")
    threads_ids = []
    posts_ids = []
    for opCell in opCells:
        threads_ids.append(opCell.get("id"))
        postCell = opCell.find_all("div",class_="postCell")
        try:
            posts_ids.append(postCell[-1].get("id"))
        except:
            posts_ids.append("none")
    array = []
    array.append(threads_ids)
    array.append(posts_ids)
    return array

def notification():
    notification = Notify()
    notification.title = "¡Mensajes nuevos!"
    notification.message = "Hay mensajes nuevos en /ac/"
    notification.icon = "C:\\proyectos_python\\icon.ico"
    notification.audio = "C:\\proyectos_python\\ping.wav"
    notification.send()

def check_equal (x,y):
    i = 0
    logic = True
    while (i<=len(x)-1 and logic):
        if (x[i]==y[i]):
            i=i+1
        else:
            logic = False
    return logic
url = "https://8chan.moe/ac"
board_info = get_info(url)
while True:
    time.sleep(10)
    board_info_new = get_info(url)
    if (not(check_equal(board_info[0],board_info_new[0]))):
        notification()
        board_info = board_info_new
    else:
        if (not(check_equal(board_info[1],board_info_new[1]))):
            notification()
            board_info = board_info_new
Edit
Pub: 13 Aug 2022 04:47 UTC
Views: 122