0
私はHTMLページから要素のリストを作成し、これらの要素の頻度を数えました。しかし、私はちょうど "bb"と "nw"のような特定の要素が必要です。だから私は彼らがどのような地位にあるのかわからないし、他の要素と区別する方法もわからない。Python:特定のリスト要素を取得する
これは、これまでの私のコードです:
from bs4 import BeautifulSoup
import urllib2
import re
import operator
from collections import Counter
from string import punctuation
source_code = urllib2.urlopen('https://de.wikipedia.org/wiki/Liste_von_Angriffen_auf_Fl%C3%BCchtlinge_und_Fl%C3%BCchtlingsunterk%C3%BCnfte_in_Deutschland/bis_2014')
html = source_code.read()
soup = BeautifulSoup(html, "html.parser")
text = (''.join(s.findAll(text=True))for s in soup.findAll('a'))
c = Counter((x.rstrip(punctuation).lower() for y in text for x in y.split()))
bb,nw=operator.itemgetter(1,2)(c.most_common())
print(bb,nw)
はあなたの助けと任意のヒントをいただき、ありがとうございます。あなたは、フィルタを使用でき
は、あなたが何を意味するのですか?頻度が必要なのですか? – Peaceful