やりたいこと
https://news.google.co.jp/news
と入力したら 「google」について、Googleニュースが世界中のニュース提供元から集約した広範囲にわたる最新情報
と出力したい。
やり方
import urllib2, time from BeautifulSoup import BeautifulSoup urls = 'https://news.google.co.jp/news' html = urllib2.urlopen(urls).read() soup = BeautifulSoup(html) print soup.findAll(attrs={"name":"description"}) [0]['content'].encode('utf-8')