当前位置:网站首页>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()边栏推荐
- 程序人生 | 测试工程师还只会点点点?7个捷径教给你快速学习新技术...
- I did these three things before the interview, and the result was actually direct
- Greedy - 53. Maximum subarray sum
- 测试用例管理工具
- jdbc使用
- Data mining-02
- 一个仿win10蓝屏的404页面源码
- Prefix-Tuning: Optimizing Continuous Prompts for Generation
- 数据丰富的计算:M.2在边缘遇到AI
- Recursion and non recursion are used to calculate the nth Fibonacci number respectively
猜你喜欢
随机推荐
Recursion and non recursion are used to calculate the nth Fibonacci number respectively
[untitled]
Crowdfunding platform system based on JSP & Servlet
【无标题】
Construction and use of FTP server and NFS server
Advanced Mathematics (Seventh Edition) Tongji University exercises 3-6 personal solutions
Embedded development: tips and techniques -- the best practice of defensive programming with C
21天,胖哥亲自带你玩转OAuth2
常用的接口测试工具
金仓数据库KingbaseES安全指南--4 数据访问保护
Simple and easy-to-use performance testing tools recommended
[prototype and prototype chain] get to know prototype and prototype chain~
xml文件使用及解析
Ch340 RTS DTR pin programming drives OLED
Jumping game II in question 45 of C language power deduction. Ergodic jump
Redis cluster
Adding DSP library to STM32F103 and its solution
test case management tool
XML file usage and parsing
Leetcode58. 最后一个单词的长度








