IRC Bot Scripting reddit / irc ---------------------------------------------------------------------- cobra447 · 2012-12-21 04:00 Hi all, Literally working up from scratch here and I could use a hand. I'd like to setup an IRC bot to basically retrieve a number from a website. The HTML is very straight forward:
0
0
Just trying to use an IRC bot to retrieve the values contained in
---------------------------------------------------------------------- Paradox · 2012-12-21 04:21 Depends on the language you're using. If you're in python, I'd look into doing something with twisted. If you're comfortable with ruby, I recommend the excellent [Cinch](https://github.com/cinchrb/cinch) gem. You could use nokogiri and the cinch gem to make a nice little bot ---------------------------------------------------------------------- cobra447 · 2012-12-21 04:22 Definitely more comfortable with python than Ruby. Thank you for the recommendations! :) ---------------------------------------------------------------------- Paradox · 2012-12-21 04:25 Python, I'd use the twisted library, urllib, and maybe even a third party HTML parser, such as beautifulsoup. If you can control what the webserver outputs, however, I'd make it output a JSON file, or even just plain text. The less parsing you have to do, the better ---------------------------------------------------------------------- drkabob · 2012-12-21 06:11 If you're looking for a Python bot, may I (shamelessly) suggest [guppy?](http://guppy.gshellz.org/cms/index.php) Its API has all the functions and bindings you would expect / need. Just use urllib or Twisted and parse. ---------------------------------------------------------------------- ifdef · 2012-12-21 10:47 Not my usual type of stuff, but here's something in Python 3: import urllib.request import re html = urllib.request.urlopen("your url here") data = str(html.read(), 'utf-8') matches = re.finditer('class="number"\>(\d+)\<', data) [match.group(1) for match in matches] Oh, and this explains what I'm doing: http://stackoverflow.com/questions/1800817/how-can-i-get-part-of- regex-match-as-a-variable-in-python ---------------------------------------------------------------------- Buttscicles · 2012-12-21 11:45 urllib is horrible, luckily I've managed to avoid it since discovering requests http://docs.python-requests.org/en/latest/ ---------------------------------------------------------------------- Paradox · 2012-12-21 11:47 I would be the wrong person to ask about python scripts. I prefer the beauty and expressiveness and other adjectives that dont mean anything of ruby ---------------------------------------------------------------------- jacobmiller · 2012-12-21 16:40 That should be easy enough using supybot. Documentation: http://supybook.fealdia.org/latest/ ---------------------------------------------------------------------- frumious · 2012-12-21 21:35 Is there a question here? ---------------------------------------------------------------------- [deleted] · 2013-01-17 09:24 [deleted] ---------------------------------------------------------------------- grys · 2013-05-26 12:35 new url http://guppy.uk.to ---------------------------------------------------------------------- grys · 2013-05-27 00:07 NEVER parse html with regex. http://docs.python.org/2/library/xml.etree.elementtree.html http://wiki.python.org/moin/PythonXml ---------------------------------------------------------------------- ifdef · 2013-05-27 02:50 parsing != pattern matching ---------------------------------------------------------------------- grys · 2013-06-08 05:08 'class="number"\>(\d+)\<' looks like an attempt to parse to me.