Reinaldo Chaves
Reinaldo Chaves

Reputation: 995

How to download images that are in links in a dataframe?

I have a dataframe with image links:

deputados_sites.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 512 entries, 0 to 511
Data columns (total 4 columns):
Nome              512 non-null object
Num_referencia    512 non-null object
Link              512 non-null object
Link_foto         512 non-null object
dtypes: object(4)
memory usage: 16.1+ KB

It is the "Link_foto" column. Data example in the column: "http://www.camara.gov.br/internet/deputado/bandep/160600.jpg" / "http://www.camara.gov.br/internet/deputado/bandep/178995.jpg"

I'm using Python3 and pandas. Please, is there a way to download these images using Python?

Upvotes: 0

Views: 1416

Answers (1)

SuperStew
SuperStew

Reputation: 3054

Something like this will probably work

import urllib.request

urllib.request.urlretrieve("http://www.camara.gov.br/internet/deputado/bandep/160600.jpg", "local-filename.jpg")

Upvotes: 2

Related Questions