0

I have a small network which includes multiple PCs and projectors. Normally, I am able to see the projector status(running time, lamp life, etc) via browser when i typed in the ip address of particular projector. I am wondering if it is possible to fetch the information of the projectors on the network using a python script. My idea is to create a small tkinter app which will display those projector status when the user request.I must admit that i am being too ambitious as i don't have enough knowledge on network programming. But if any of you can help me out , i will greatly appreciate.

Chris Aung
  • 9,152
  • 33
  • 82
  • 127

2 Answers2

0

you can do it several ways, but since you have not given so much information I would recommend going with mechanize or splinter, both work as a browser so you can read what's on the HTML and even fill/submit forms and much more.

PepperoniPizza
  • 8,842
  • 9
  • 58
  • 100
0

It sort of depends on how complicated the page is. If it's plain text, then something like this should work

import urllib
stats_text = urllib.urlopen('http://ip.of.projector').read()

If you need to parse the returned page at all to extract the values, you might want to look at BeautifulSoup

Adam Obeng
  • 1,512
  • 10
  • 13
  • It works like a champ! thanks a lot. the only problem i am having now is that when i run the script, it ask me to enter user name and password to access the page. Is there anyway to automate the process? – Chris Aung Mar 18 '13 at 08:59
  • If the page is using HTTP Basic Authentication, the solutions in [this thread](http://stackoverflow.com/questions/635113/python-urllib2-basic-http-authentication-and-tr-im) might work for you. – Adam Obeng Mar 18 '13 at 16:21
  • thanks Adam, it works! i think it's time for me to do some parsing with beautiful soup. Again, thanks a lot for all your help! – Chris Aung Mar 19 '13 at 03:53