返回顶部
热门问答 更多热门问答
技术文章 更多技术文章

python学习笔记:下载URL的图片和读取URL内容

[复制链接]
前方录 显示全部楼层 发表于 2024-3-7 08:20:12 |阅读模式 打印 上一主题 下一主题

登录网站,浏览更多精彩内容

您需要 登录 才可以下载或查看,没有账号?加入我们

x
下载URL图片

[mw_shl_code=python,false]import requests
url = "http://antpython.net/static/pubdatas/webspider/goodimgs/9.jpeg"
r = requests.get(url)
with open("p098.jpeg", "wb") as f:
    f.write(r.content)[/mw_shl_code]



打印URL文件的内容

[mw_shl_code=python,false]import requests

r = requests.get("http://antpython.net/static/py100/life_is_great.txt")
print(r.text)[/mw_shl_code]
中国领先的数字技术资源交流中心!
商乾全球电商人、电商交流学习与电商实战技术分享、电商爬虫、生活交流专业网站
  • 官方手机版

  • 微信公众号

  • 商务合作