あなたは「ガチョウ」モジュールを使用してページ上のすべてのテキストを抽出するのであればどのような、そして、すべてのものを反復し、与えられた文章中のキーワードを見つけ、このような何か:
from goose import Goose
keyword = 'I can only extract paragraphs'
g = Goose(config={'enable_image_fetching':False})
article = g.extract(url='https://stackoverflow.com/questions/44444456/extract-the-provided-text-whole-paragraph-where-ever-the-text-present-in-webpa')
text = article.cleaned_text
_sent = [sent for sent in text.split('\n') if keyword in sent]
print _sent
#[u'is there any method ?? so that ""I can only extract paragraphs or Description using the keyword""']
がUPDATE:追加のモジュールが必要:pyteaser。あなただけのテキストにキーワードを含めることを確認してください段落全体が必要な場合は、関数が用意キーワード
from pyteaser import Summarize
from goose import Goose
def teaser(title,text):
summaries = Summarize(title,text)
return summaries
g = Goose(config={'enable_image_fetching':False})
article = g.extract(url='http://en.wikipedia.org/wiki/Rahul_Dravid')
text = article.cleaned_text
print teaser('Dravid',text)
出典
2017-06-08 20:36:57
brc
得点に基づいて、第1の5 sentsを返す '場合article.cleaned_textのキーワード:'これは本当に私に提供しなかったことを言って申し訳ありません – brc
私が望むソリューション#brc –
あなたはもっと具体的になりますか?現在のWebページの例、抽出する必要があるデータ、使用するキーワード – brc