Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Web scraping
#1
I would like to make simple script that returns 0 when server is offline and 1 when server is online, using web scraping. From that webpage "http://tera.enmasse.com/server-status".

Thanks!
Reply
#2
Hi! You will be best off by using Python modules requests and BeautifulSoup.
And you won't need to go far to start with web scraping, there are some nice tutorials right here on our forums!
https://python-forum.io/Thread-Web-Scraping-part-1

Good luck and let us know if you hit any obstacles!
Reply
#3
There are a ton of sites that check whether another site is active. There might be one with an API that you can just get JSON of a simple ON/OFF switch
Recommended Tutorials:
Reply
#4
Here a tips after taking a quick look at site.
Server status one image(icon) that push up and down based on server status.
Server-up has 'data-value': '1' server-down 'data-value': '8'.
Example first server.
from bs4 import BeautifulSoup
import requests

url = 'http://tera.enmasse.com/server-status'
url_get = requests.get(url)
soup = BeautifulSoup(url_get.content, 'lxml')
first = soup.select('.server-status-icon')
Test:
>>> first[0].attrs
{'class': ['server-status-icon'], 'data-value': '8'}
>>> first[0].attrs['data-value']
'8'
Reply
#5
Thank You everybody so much for helping me with this. I'll check out all the answers and try to go on with this matter in my hands. The issue that led me to make thread was just one piece in the puzzle. Thank You all you were definitely great help!
Reply


Forum Jump:

User Panel Messages

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