代码如下:
import re
with open('data_1.html','r',encoding='utf-8') as f:
data = re.sub('\n','',f.read())
print(data)
pattern_1 = '<span class="title ellipsis-2" title="(.*?)">(.*?)</span>'
pattern_2 = '<em>(.*?)</em>'
pattern_3 = '<i>(.*?)</i>'
book_price_s = re.findall(pattern_3,data)
book_pay = re.findall(pattern_2,data)
book_name_s = re.findall(pattern_1,data)
for book_name in book_name_s:
book_name = book_name[0].strip()
print(book_name)
# for book_price_hour in book_price_hour_s:
# # print(book_price_hour)
for book_price in book_price_s:
book_price = book_price.strip()
print(book_price.strip())
list_s = []
for date_s in data:
list_s.append(
{
'book_name':book_name,
'book_price_hour':book_pay,
'book_price':book_price
}
)
print(list_s)
请问我这段代码有什么问题吗?