这个我是拿来参考的 

import requests

def url_open(url):
    response = requests.get(url)
    html = response.content
    return html


url="http://jandan.net/ooxx/"

html=url_open(url).decode("utf-8")
image_urllist=[]
a=html.find("img src=")
while a!=-1:
    b=html.find("jpg",a,a+255)
    if b!=-1:
        image_urllist.append("http:"+html[a+9:b+4])
    else:
        b=a+9
    a=html.find("img src=",b)

count=0
for index,each in enumerate(image_urllist):
    # filename=each.split("/")[-1]
    filename=str(count)+".jpg"
    with open(filename,"wb") as f:
        img=url_open(each)
        f.write(img)
        print(each)
    if index>3:
        break
    count+=1

 

相关文章:

  • 2021-06-19
  • 2022-12-23
  • 2021-04-24
  • 2022-12-23
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-27
  • 2021-06-21
  • 2021-11-21
  • 2022-12-23
  • 2021-10-19
  • 2021-07-26
  • 2022-12-23
相关资源
相似解决方案