当前位置:网站首页>Shell rental reptile
Shell rental reptile
2022-07-28 04:01:00 【SingYi】
import urllib.request as request
from bs4 import BeautifulSoup
import os
def downloadImg(url: str, name):
soup = BeautifulSoup(str(request.urlopen(url).read(), encoding='utf-8'), features='html.parser')
savePath = f"./result/images/{name.replace('/', '-')}"
if not os.path.exists(savePath):
os.mkdir(savePath)
for img in soup.select('div.content__article__slide__item > img'):
img = img.get('data-src')
with open(f"{savePath}/{img.split('/')[-1].split('!')[0].split('?')[0]}", 'wb') as f:
f.write(request.urlopen(img).read())
def a():
with open('./result/list.txt', 'w', encoding='utf-8') as f:
for i in range(1, 11):
url = f'https://cs.zu.ke.com/zufang/pg{i}/#contentList'
data = str(request.urlopen(url).read(), encoding='utf-8')
soup = BeautifulSoup(data, features='html.parser')
for item in soup.find_all('div', attrs={'class': 'content__list--item'}):
imgTag = item.find('img')
imgUrl = imgTag.get('data-src')
print(imgUrl)
title = imgTag.get('alt')
print(title)
downloadImg(
f"https://cs.zu.ke.com{item.find('a', attrs={'class': 'content__list--item--aside'}).get('href')}",
title)
des = item.find('p', attrs={'class': 'content__list--item--des'}) \
.get_text().replace('\n', '').replace(' ', '')
print(des)
price = item.find('span', attrs={'class': "content__list--item-price"}).get_text()
print(price)
tags = [tag.get_text() for tag in
item.find('p', attrs={'class': 'content__list--item--bottom oneline'}).select('p > i')]
print(tags)
f.write(f'{title},{des},{price},{tags}\n')
print('*' * 30)
if __name__ == '__main__':
os.mkdir('/result')
a()边栏推荐
- conda虚拟环境总结与解读
- Fourier series
- un7.27:如何在idea中成功搭建若依框架项目?
- Experience sharing of automatic test for students with monthly salary of 28K
- 静态博客搭建工具汇总
- WordPress简约mkBlog博客主题模板v2.1
- CH340 RTS DTR引脚编程驱动OLED
- Lightpicture - exquisite drawing bed system
- Dynamic planning - 62. Different paths
- [openvx] VX for basic use of objects_ pyramid
猜你喜欢

【图像分类】2021-MLP-Mixer NIPS

Advanced Mathematics (Seventh Edition) Tongji University exercises 3-4 personal solutions (first 8 questions)

Servlet usage

Protocols in swift

It's amazing. This article completely explains the service interface testing

Experience sharing of automatic test for students with monthly salary of 28K

Adding DSP library to STM32F103 and its solution

Monotonic stack - 739. Daily temperature

Data mining-01

Is there a bonus period for robot engineering
随机推荐
Interview essential skills: SQL query special training!
Do you regret doing automated testing?
Notes on writing questions in sword finger offer
MySQL是怎么保证高可用的
Crowdfunding platform system based on JSP & Servlet
JDBC usage
Appnium -- app automated test tool
How does MySQL ensure high availability
Do Netease and Baidu have their own tricks for seizing the beach AI learning machine?
Greed - 55. Jumping game
Greedy - 53. Maximum subarray sum
Advanced Mathematics (Seventh Edition) Tongji University exercises 3-4 personal solutions (the last 8 questions)
Detailed explanation of string + memory function (C language)
H265/HEVC名词解释-- CTU,CTB,CU,CB,TU,PU,TB,PB,LCU,Slice,Tile,Chroma,Luma,I帧,B帧,P帧
Prefix-Tuning: Optimizing Continuous Prompts for Generation
【无标题】
面试必备杀技:SQL查询专项训练!
LeetCode 0141. 环形链表 - 三种方法解决
金仓数据库KingbaseES安全指南--6.1. 强身份验证简介
My creation anniversary