1
<p class="mrgn-bttm-0 pop text-center" title="Chance of Precipitation"><small> 30%</small></p>
上記の例のpタグから "Chance of Precipitation 30%"を抽出します。これらのタグは実際には14個あり、毎日1個です。私はすべてのpタグを使用しています。Pタグからタイトルを抽出するには
f = soup.find('details', {'class':"panel panel-default wxo-fcst"})
は、その後、私が試してみました:
for i in f:
print i.find('p')['title']
と
for i in x.findAll("p"):
print i.find('p')['title'])
が、私はどこにもなっていないのです。誰か助けてもらえますか?
てみ '[P [ 'タイトル'] + p.text.strip()f.findAllのpのために(P ' ')] '? – Psidom
あなたはclass = "mrgn-bttm-0 pop text-center"を持っていますが、変数 "f" classに従っています: "panel panel-default wxo-fcst" – Zydnar
あなたの提案を使用して "Exception is 'タイトル'"。私はhttps://weather.gc.ca/city/pages/ab-52_metric_e.htmlからのデータに触れようとしています。 f = soup.find( '詳細'、{'クラス': "パネルパネル - デフォルトwxo-fcst"})は、私がタイトルを掻きたいと思うすべてのpを与えます。 –