Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script running on a server
#1
I'm new to Python and I created a script running on Chrome webdriver.
How can I create the same script that I can keep it running on a cloud server 24/7?

It's a simple bot, just login in to a website, and click on a submit button.


from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.webdriver.common.by import By

driver = webdriver.Chrome('C:/chromedriver.exe')

def timekiller():
user = 'user'
psw = 'pass'
driver.get('http://www.mypage.com')
sleep(5)
driver.find_element_by_id('slogin').click()
sleep(5)
userid = driver.find_element_by_name('username').send_keys(user)
psw = driver.find_element_by_name('password').send_keys(psw)
sleep(5)
driver.find_element_by_class_name("form-group").submit()
sleep(5)
driver.get('http://xxx.com/like?type=photo')
sleep(10)
driver.find_element_by_id('get_likes_button').click()
sleep(45)
driver.get('http://www.mypage.com/logout')

while True:
try:
timekiller()
except Exception:
driver.get('http://www.mypage.com/logout')
Reply
#2
You can add a cron job to run the script every whatever time you want.
https://www.htlinux.com/how-to-cron-jobs-in-linux/

The alternate solution is to put it in a loop and repeat and let it run indefinitely using tmux to split out of the terminal and leave while its running.
https://hackernoon.com/a-gentle-introduc...784c404340
Recommended Tutorials:
Reply
#3
Also, in the future, please use code tags! I went to do it for you but the indentation still looked broken, you need to make sure that the indentation is correct in your posts.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  No Internet connection when running a Python script basil_555 8 442 Mar-11-2024, 11:02 AM
Last Post: snippsat
Question Running Python script through Task Scheduler? Winfried 8 335 Mar-10-2024, 07:24 PM
Last Post: Winfried
  Triggering a ps1 script in remote windows server via http python request jasveerjassi 1 317 Jan-26-2024, 07:02 PM
Last Post: deanhystad
  Help Running Python Script in Mac OS emojistickers 0 306 Nov-20-2023, 01:58 PM
Last Post: emojistickers
  Trying to make a board with turtle, nothing happens when running script Quascia 3 607 Nov-01-2023, 03:11 PM
Last Post: deanhystad
  Python script running under windows over nssm.exe JaroslavZ 0 671 May-12-2023, 09:22 AM
Last Post: JaroslavZ
  Running script with subprocess in another directory paul18fr 1 3,476 Jan-20-2023, 02:33 PM
Last Post: paul18fr
  How to modify python script to append data on file using sql server 2019? ahmedbarbary 1 1,175 Aug-03-2022, 06:03 AM
Last Post: Pedroski55
  Real-Time output of server script on a client script. throwaway34 2 2,010 Oct-03-2021, 09:37 AM
Last Post: ibreeden
  How to take the tar backup files form remote server to local server sivareddy 0 1,871 Jul-14-2021, 01:32 PM
Last Post: sivareddy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020