-1

need help with this code, i want the bot open the site every 24h but not on Friday and Saturday how can i do it?

import webbrowser
from pynput.mouse import Button, Controller
import time

print("Hello! Welcome to 1Report Destroyer")
time.sleep(2)
print("From now, you have nothing to worry about")
time.sleep(2)
print("LET ME DO YOUR JOB")

while True:
    time.sleep(86400)
    print("lets Destroy")
    webbrowser.open("https://one.prat.idf.il/finish")
    mouse = Controller()
    print("Current position: " + str(mouse.position))
    mouse.position = (949, 555)
    print("Current position: " + str(mouse.position))
    time.sleep(5)
    mouse.click(Button.left, 1)
    print("ON YOUR FACE 1REPORT")

2 Answers2

0

Use the datetime library

from datetime import datetime

Then just include an if statement in you're while loop with something like:

if datetime.today().strftime('%A') not in ['Friday', 'Saturday']:
    # Query site 

or

if datetime.today().weekday() < 4 or datetime.today().weekday() > 5:
    #Query site
difurious
  • 1,523
  • 3
  • 19
  • 32
0

You can try something like this:

import datetime  
from datetime import date 
import calendar 

today = date.today()
TODAY =  today.strftime("%d %m %Y")

def findDay(date): 
   day, month, year = (int(i) for i in date.split(' '))     
   day = datetime.date(year, month, day) 
   return day.strftime("%A") 


print(findDay(TODAY)) 

then you can run a if statement!