i have many classes having name marginbegin
. want find date in whole code.
html code:
<div class="marginbegin"> <dl> <dt><label>delivered on:</label></dt> <!--fsrhiddenblockstart--><dd><!--fsrhiddenblockstart--> friday, 06/17/2016 at 3:02 p.m. <!--fsrhiddenblockend--></dd><!--fsrhiddenblockend--> </dl>
my result:
06/17/2016
i think work.
from bs4 import beautifulsoup import re soup = beautifulsoup(open("file.html")) link in soup.findall("div", { "class" : "marginbegin" }): string= link.contents[1].findall("dd") date=re.search(r'(\d+/\d+/\d+)',(str(string[0]))) print(date.group(1))
Comments
Post a Comment