import requests
import re
import urllib.request

def getHtml(url):
    page = requests.get(url)
    html = page.text
    return html

def getImg(html):
    reg = r'src="(.+?\.jpg)" alt'
    imgre = re.compile(reg)
    imglist = re.findall(imgre,html)
    x = 0
    for imgurl in imglist:
        urllib.request.urlretrieve("https:"+imgurl,'%s.jpg' % x)
        x+=1


html = getHtml("https://www.qiushibaike.com/imgrank/")

print (getImg(html))

爬虫糗事百科首页图片代码~

相关文章:

  • 2021-11-04
  • 2021-12-10
  • 2021-12-10
  • 2021-07-25
  • 2021-12-10
  • 2021-12-10
  • 2021-08-20
猜你喜欢
  • 2021-12-10
  • 2021-12-10
  • 2021-12-10
  • 2021-12-10
  • 2021-12-10
  • 2021-04-11
相关资源
相似解决方案