PythonでBeautifulSoupを使用して、ページのソースコードから時間範囲を取得しようとしています。BeautifulSoup - クラスを見つけて別のクラスを除外
私はこの
<span class="experience-date-locale"><time>June 2010</time> – <time>August 2010</time> (3 months)<span class="locality">New York</span></span>
<span class="experience-date-locale"><time>October 2015</time> – Present (7 months)</span>
<span class="experience-date-locale"><time>May 2010</time> – <time>October 2011</time> (6 months)</span>
のように見える解析しようとしていると私はいつか私も「地域」クラスを持つbecuase私はdidntの仕事をしようとした右
この行を、それを取得する方法を知らないライン...
soup.find('span', {'class': 'experience-date-locale'}).text
これは私が 'が存在' 部分
を欠場becuaseあまりにも動作しません。場所の一部を除外して時間を取得するにはどうすればよいですか?
結果は次のようになります。
June 2010 - August 2010 (3 months)
October 2015 - present (7 months)
May 2010 - October 2011 (6 month)
第二のスニペットの結果は何ですか? –
@LutzHornはAttributeErrorをスローします。実際には、実際には日付が "現在"ある場合、それが問題を解決しない原因となるのを助けてくれません –
以下の回答のいずれかが役に立ちますか? –