from bs4 import BeautifulSoup
import requests
import urllib.request
import random
import time
x = 0
def getDbImage(page=1):
response = requests.get('https://www.dbmeinv.com/?pager_offset={}'.format(page))
html = response.text
soup = BeautifulSoup(html, 'lxml')
girl = soup.select('img')
for img in girl:
link = img.get('src')
global x
urllib.request.urlretrieve(link, 'images/{}.jpg'.format(x))
x += 1
print('正在下载第{}张图片'.format(x))
for i in range(1, 50):
print("正在下载第{}页图片".format(i))
time.sleep(1 + random.random())
getDbImage(i)
网友评论