Python Forum
Web scraping - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Web scraping (/thread-7629.html)



Web scraping - BoiledGoose - Jan-18-2018

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!


RE: Web scraping - j.crater - Jan-18-2018

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!


RE: Web scraping - metulburr - Jan-18-2018

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


RE: Web scraping - snippsat - Jan-18-2018

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'



RE: Web scraping - BoiledGoose - Jan-20-2018

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!