#play ul>li{ float: left; width: 220px; height: 308px; overflow: hidden; position: relative; }添加注释
时间: 2023-12-13 16:07:42 浏览: 32
/* 设置列表样式为无序列表,并对列表项进行以下样式设置 */
ul>li{
float: left; /* 将列表项设置为浮动,让多个列表项横向排列 */
width: 220px; /* 设置列表项的宽度 */
height: 308px; /* 设置列表项的高度 */
overflow: hidden; /* 设置溢出内容隐藏 */
position: relative; /* 设置相对定位,方便后续操作 */
}
相关问题
.audio div button.play-pause { width: 36px; height: 36px; border-radius: 50%; background-color: #fff; margin-left: 12px; align-self: center; }
这是一个CSS选择器,它用于设置音频播放器的样式。`.audio div button.play-pause`表示匹配`class`属性包含`audio`的`div`元素下的`class`属性包含`play-pause`的`button`元素。这个样式将播放/暂停按钮的宽度和高度都设置为36像素,并且将按钮的边框半径设置为50%,使其呈圆形。它还将按钮的背景色设置为白色,并在左侧设置12像素的外边距,使其与其他元素保持一定的间距。最后,它使用`align-self`属性将按钮垂直居中对齐。这个样式的实现可能还有其他的CSS属性和JavaScript代码,用于设置音频播放器的其他部分的样式,例如进度条、音量控制等。
#解析数据 detail_selector = parsel.Selector(detail_html) title = detail_selector.css('.b_crumb_cont *:nth-child(3)::text').get() comment = detail_selector.css('.title white::text').get() view_count = detail_selector.css('.view_count::text').get() date = detail_selector.css('#js_mainleft > div.b_foreword > ul > li.f_item.when > p > span.data::text').get() days = detail_selector.css('#js_mainleft > div.b_foreword > ul > li.f_item.howlong > p > span.data::text').get() money = detail_selector.css('#js_mainleft > div.b_foreword > ul > li.f_item.howmuch > p > span.data::text').get() character = detail_selector.css('#js_mainleft > div.b_foreword > ul > li.f_item.who > p > span.data::text').get() play_list = detail_selector.css('#js_mainleft > div.b_foreword > ul > li.f_item.how > p > span.data > span::text').getall() for play in play_list: print(play) print(title, comment, view_count, date, days, money, character, play_list, detail_url) time.sleep(random.randint(3,5))这段代码为什么只能输出最后一个网站的内容,应该怎么修改
这段代码只输出最后一个网站的内容是因为在循环中只是将每个play输出了,并没有将其他的信息输出。可以将每个网站的信息放在一个字典中,再将这些字典放在一个列表中,最后输出整个列表即可。修改后的代码如下:
```
detail_selector = parsel.Selector(detail_html)
title = detail_selector.css('.b_crumb_cont *:nth-child(3)::text').get()
comment = detail_selector.css('.title white::text').get()
view_count = detail_selector.css('.view_count::text').get()
date = detail_selector.css('#js_mainleft > div.b_foreword > ul > li.f_item.when > p > span.data::text').get()
days = detail_selector.css('#js_mainleft > div.b_foreword > ul > li.f_item.howlong > p > span.data::text').get()
money = detail_selector.css('#js_mainleft > div.b_foreword > ul > li.f_item.howmuch > p > span.data::text').get()
character = detail_selector.css('#js_mainleft > div.b_foreword > ul > li.f_item.who > p > span.data::text').get()
play_list = detail_selector.css('#js_mainleft > div.b_foreword > ul > li.f_item.how > p > span.data > span::text').getall()
result_list = []
for play in play_list:
result_dict = {}
result_dict['title'] = title
result_dict['comment'] = comment
result_dict['view_count'] = view_count
result_dict['date'] = date
result_dict['days'] = days
result_dict['money'] = money
result_dict['character'] = character
result_dict['play'] = play
result_dict['detail_url'] = detail_url
result_list.append(result_dict)
print(result_dict)
time.sleep(random.randint(3,5))
```
这样就能够输出每个网站的所有信息了。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)