How to programmatically download image from website?

后端 未结 4 1577
面向向阳花
面向向阳花 2021-01-15 19:15

I need to download images from a website, and I have the login name and password, but if i just use URL to download the image, it will throw a exception: there is no value i

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-15 19:36

    In simple circumstances you can use a URLConnection with the URL and stream the contents down. More generally I'd strongly advise you use Apache HttpClient since you'll need to do authentication and possibly receive and send cookies to the server. Read the user guide regarding Authentication and Methods, particularly Get.

提交回复
热议问题