Posted By

tamuratetsuya on 03/17/09


Tagged

google python engine app django


Versions (?)

wikipediaに単語があるかどうかのチェック


 / Published in: Python
 

  1. def checkWiki(word):
  2. if word != '':
  3. url = 'http://ja.wikipedia.org/wiki/'+urllib.quote(word.encode('utf-8'))
  4. #getHtml=unicode(urlfetch.fetch(url).content,'cp932')
  5. getHtml=urlfetch.fetch(url).content
  6. html_analyzed = BeautifulSoup(getHtml)
  7. for node in html_analyzed.findAll('div', {'class': 'plainlinks'}):
  8. #print >>sys.stderr,'node=%s'%node('b')[0](text = True)[0]
  9. if node('b')[0](text = True)[0].find(u'ありません')==-1:
  10. print >>sys.stderr,'yes'
  11. return 1
  12. else:
  13. print >>sys.stderr,'ng'
  14. return 0
  15. return 1
  16. else:return 0

Report this snippet  

You need to login to post a comment.