/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def checkWiki(word): if word != '': url = 'http://ja.wikipedia.org/wiki/'+urllib.quote(word.encode('utf-8')) #getHtml=unicode(urlfetch.fetch(url).content,'cp932') getHtml=urlfetch.fetch(url).content html_analyzed = BeautifulSoup(getHtml) for node in html_analyzed.findAll('div', {'class': 'plainlinks'}): #print >>sys.stderr,'node=%s'%node('b')[0](text = True)[0] if node('b')[0](text = True)[0].find(u'ã‚ã‚Šã¾ã›ã‚“')==-1: print >>sys.stderr,'yes' return 1 else: print >>sys.stderr,'ng' return 0 return 1 else:return 0