Instad从.downloads获取响应我想要一个url来触发它,并从BeautifulSoup获得响应,我很新的python,这只是像我的第三个项目。需要使这个irc bot与BeautifulSoup一起工作
#!/usr/bin/env python
import botlib
import urllib
import BeautifulSoup
class StaffBot(botlib.Bot):
def __init__(self, server, channel, nick, password=None):
botlib.Bot.__init__(self, server, 6667, channel, nick)
if password != None:
self.protocol.privmsg("nickserv", "identify" % password)
def __actions__(self):
botlib.Bot.__actions__(self)
if botlib.check_found(self.data, ".downloads"):
username = self.get_username()
self.protocol.privmsg(self.channel, "%s: response" % username)
if __name__ == "__main__":
StaffBot("irc.rizon.net", "#chan", "nick").run()
只是套内我那个做错了.... http://pastebin.com/AhrssPVW
的BeautifulSoup脚本即时通讯使用。
soup = BeautifulSoup.BeautifulSoup(urllib.urlopen("url"))
print soup.title.string
编辑
我有点失败了我想说的,我想,以取代.downloads说website.net/viewtopic.php。所以有人说这个网站(如下图)回复了页面标题。
somone>>>website.net/viewtopic.php?f=6&t=10960
bot>>>WebsiteName • Viewtopic - topicname
那么你什么时候试图找到一个url?目前您不会从'urllib.urlopen('url')'获取内容,因为您正在向它传递一个字符串。 – dm03514 2012-08-17 14:11:38
该网址将来自我的irc频道上的用户,我想添加beautifulsoup到机器人中,以便用户从我们的网站输入网址。例。 http://website.net/viewtopic.php将成为触发器而不是.downloads。 – user1425964 2012-08-17 14:17:25