Created
August 26, 2010 10:14
-
-
Save yuiseki/551180 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# とりあえずsocial streamの埋め込みページからスクレイピングで検索条件を特定する | |
from BeautifulSoup import BeautifulSoup | |
stream = "http://www.ustream.tv/socialstream/%s" % channel_id | |
html = urllib.urlopen(stream) | |
soup = BeautifulSoup(html.read()) | |
scripts = soup.findAll('script') | |
# scriptタグのUstream.Vars.messageSuffix=" (#akibaust live at http:\/\/ustre.am\/kpMv )"というあたりの文字列 | |
suffix = scripts[2].string.split(';')[8] | |
# #akibaust というあたりの文字列 | |
logger.debug("social word suffix: %s" % suffix) | |
tweet = re.search(r"(@|#)([\w|\\]+)", suffix).group(0) | |
logger.debug(tweet) | |
ref_tweet = _ref2unicode(tweet) | |
logger.debug(ref_tweet) | |
return ref_tweet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment