In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "Python automation script deployment server method", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Python automation script deployment server method" it!
1. Preface
If the daily Python automation program runs stably locally, you can consider deploying it to the server and completely liberate your hands with scheduled tasks.
However, because automated programs are associated with platform compatibility, there are some dependent libraries that need special handling when running on the server.
two。 Operation steps
Take CentOS server as an example
2-1 install desktop environment
PS: if it is already installed, you can skip to the next step
We need to install a desktop environment "take GNOME as an example", set it to start in graphical mode, and open the graphical interface.
# install GNOME Desktop Environment yum groupinstall-y "GNOME Desktop" # set to launch systemctl set-default graphical.target in graphical mode # Open graphical interface startx2-2 install and configure remote Desktop
Take the most common VNC as an example
First, install VNC Server on the server and set the login password
# install vnc server yum install tigervnc-server-y # set login password for vnc viewer login password vncpasswd
Then, start VNC Server and open the corresponding port number
# enable VNC service systemctl start vncserver@:1 # set boot systemctl enable vncserver@:1 # View VNC service port netstat-lnpt | grep Xvnc # enable port number firewall-cmd-- add-port=5901/tcp-- permanent firewall-cmd-- reload
Finally, download VNC Viewer and remotely connect to the server using "IP address + port number + login password"
Download address:
Https://www.realvnc.com/en/connect/download/viewer/
PS:VNC Server explicitly specifies the IP address + port number
2-3 install Chrome browser
The browser installed by default on the server is FireFox,Chrome browser. You need to install it manually.
# download the latest Chrome browser wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm # install browser yum install google-chrome-stable_current_x86_64.rpm # check the version of Chrome browser google-chrome- version
After the installation is completed, it is found that using the Root user to launch the Chrome browser failed PS: the server Chrome browser does not support direct use. You need to start it with-- no-sandbox parameter.
# launch the Chrome browser in-- no-sandbox mode # method 1: command line launch / usr/bin/google-chrome-stable-- no-sandbox # method 2: modify the startup method of the Chrome browser shortcut icon # startup method:-- no-sandbox2-4 configure Chrome Driver and authorization
Download the corresponding version of Chrome Driver of the Chrome browser on the official website.
Download address:
Http://chromedriver.storage.googleapis.com/index.html
After decompressing, upload it to the server's "usr/bin" directory.
Finally, grant executable permissions to the chromedriver file
[root@localhost xh] # cd / usr/bin # Grant executable permissions [root@localhost bin] # sudo chmod + x chromedriver2-5 Visualized run Test
Upload the automation script to the server and set it to run in header mode
Note: since the Chrome of the server needs to be configured to start in no-sandbox mode, the automation script needs to add setting properties
Option = webdriver.ChromeOptions () # run in headless mode # option.add_argument ('headless') option.add_argument (' no-sandbox') option.add_argument ('disable-dev-shm-usage') option.add_experimental_option (' useAutomationExtension', False) option.add_experimental_option ('excludeSwitches', [' enable-automation']) browser = webdriver.Chrome (chrome_options=option)
After the headless mode test runs properly, you can turn on headless mode, write scheduled tasks, and associate automation scripts with scheduled tasks.
3. Last
In this paper, the step flow of deploying server with Selenium automation script is described.
It should be pointed out that visual debugging testing on the server is really necessary, which can help us to locate compatibility issues in advance.
At this point, I believe you have a deeper understanding of "Python automation script deployment server method", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.