当前位置:网站首页>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()边栏推荐
- Advanced Mathematics (Seventh Edition) Tongji University exercises 3-5 personal solutions
- From Clickhouse to Snowflake: MPP query layer
- Practical scripts of mangopapa (contents)
- Summary and interpretation of CONDA virtual environment
- conda虚拟环境总结与解读
- Do you regret doing automated testing?
- WordPress simple mkblog blog theme template v2.1
- C语言:求一个整数存储在内存中的二进制中1的个数
- Protocols in swift
- 【luogu P4590】游园会(DP套DP)
猜你喜欢

Detailed explanation of pointer written test questions (C language)

Security exception handling mechanism

一文读懂Plato Farm的ePLATO,以及其高溢价缘由

ServletContext、request、response

From Clickhouse to Snowflake: MPP query layer

Greedy - 53. Maximum subarray sum
![[leetcode] 34. Find the first and last positions of elements in the sorted array](/img/f0/3eaa33fa7b13abe5f27b136239507d.png)
[leetcode] 34. Find the first and last positions of elements in the sorted array

Common interface testing tools

UBI read only file system

测试用例管理工具
随机推荐
高等数学(第七版)同济大学 习题3-5 个人解答
Leetcode 0140. word splitting II
Monotonous stack -- 42. Receiving rain -- a difficult problem that big factories must know
静态博客搭建工具汇总
Embedded development: tips and techniques -- the best practice of defensive programming with C
Jumping game II in question 45 of C language power deduction. Ergodic jump
TypeError: ufunc ‘bitwise_ and‘ not supported for the input types, and the inputs could not be safely
Do you regret doing automated testing?
Security exception handling mechanism
xml文件使用及解析
LeetCode 0141. 环形链表 - 三种方法解决
搬家通知!
Leetcode58. 最后一个单词的长度
Advanced Mathematics (Seventh Edition) Tongji University exercises 3-6 personal solutions
Screenshot of deepstream detection results
Construction and use of FTP server and NFS server
Servlet usage
金仓数据库KingbaseES安全指南--6.1. 强身份验证简介
超好用的 PC 端长截图工具
Interface automation test, complete introduction