Skip to content

Instantly share code, notes, and snippets.

@yuiseki
Created August 26, 2010 10:14
Show Gist options
  • Save yuiseki/551180 to your computer and use it in GitHub Desktop.
Save yuiseki/551180 to your computer and use it in GitHub Desktop.
# とりあえず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