a= soup.find_all('p',class_= "time_font_size shadow shukkin_detail_time")
から下記のデータを得ました。
<p class="time_font_size shadow shukkin_detail_time"><i class="fa fa-clock-o"></i>9:00~17:00</p>, <p class="time_font_size shadow shukkin_detail_time"><i class="fa fa-clock-o"></i>9:00~17:00</p>, <p class="time_font_size shadow shukkin_detail_time"><i class="fa fa-clock-o"></i>10:00~21:00</p>, <p class="time_font_size shadow shukkin_detail_time"><i class="fa fa-clock-o"></i>10:00~23:59</p>, <p class="time_font_size shadow shukkin_detail_time"><i class="fa fa-clock-o"></i>12:00~22:00</p>,9:00~17:00 のようなテキストだけを得たかったので
print(a.text)
と、してみましたが
AttributeError Traceback (most recent call last) Input In [23], in <cell line: 1>() ----> 1 print(a.text) File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/bs4/element.py:2253, in ResultSet.__getattr__(self, key) 2251 def __getattr__(self, key): 2252 """Raise a helpful exception to explain a common code fix.""" -> 2253 raise AttributeError( 2254 "ResultSet object has no attribute '%s'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?" % key 2255 ) AttributeError: ResultSet object has no attribute 'text'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?
てしまいました。
最終的には時間だけを抜き出して17−9=8のように出勤時間の総計を出したいと考えております
回答1件
あなたの回答
tips
プレビュー