ultralytics / flickr_scraper

Simple Flickr Image Scraper
https://ultralytics.com
GNU Affero General Public License v3.0
214 stars 62 forks source link

Script won't pull photos #5

Open Fahrenheit opened 3 years ago

Fahrenheit commented 3 years ago

I attempted to use the command suggested and have tried to pull other things however I always get this error. It creates the necessary folders, but won't grab any of the photos. Not quite sure how to fix this. Any help would be much appreciated!

`flickr_scraper` % python3 flickr_scraper.py --search 'honeybees' --n 10 --download           
Traceback (most recent call last):
  File "/Users/fah/Projects/flickr_scraper/flickr_scraper.py", line 62, in <module>
    get_urls(search=opt.search,  # search term
  File "/Users/fah/Projects/flickr_scraper/flickr_scraper.py", line 31, in get_urls
    for i, photo in enumerate(photos):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/flickrapi/core.py", line 690, in data_walker
    photoset = rsp.getchildren()[0]
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren'
glenn-jocher commented 3 years ago

@Fahrenheit script works correctly, just tested it today 16 January 2021 in a Colab notebook.

Screen Shot 2021-01-16 at 9 22 00 PM
Fahrenheit commented 3 years ago

@Fahrenheit script works correctly, just tested it today 16 January 2021 in a Colab notebook.

Screen Shot 2021-01-16 at 9 22 00 PM

Odd, I still can't get it to work.

glenn-jocher commented 3 years ago

@Fahrenheit are you using the Flickr API key and secret as in the README instructions? https://github.com/ultralytics/flickr_scraper#use

Fahrenheit commented 3 years ago

@Fahrenheit are you using the Flickr API key and secret as in the README instructions? https://github.com/ultralytics/flickr_scraper#use

Yes, I am. I'll try a new API key and see if that works.

guillaumedavidphd commented 3 years ago

I think this might be related to the deprecation of getchildren in Python 3.9. See https://docs.python.org/3.8/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.getchildren.

glenn-jocher commented 3 years ago

@guillaumedavidphd thanks for the info! We don't use this in ultralytics/flickr_scraper but I see it is used in the flickrapi package.

@Fahrenheit perhaps downgrading your python to 3.8 might solve this?

gpotte commented 3 years ago

Thanks this worked !!

snippsat commented 3 years ago

Hi i did help with someone with this error on python-forum.io
First show how to run Python 3.8 in environment with py(no need to downgrade)

# Make environment with Python 3.8 
G:\div_code\py -3.8 -m venv flick38_env  

Then i looked at error.
In core.py line 690.

#photoset = rsp.getchildren()[0]  
photoset = list(rsp)[0] # Fix for Python 3.9

Test with Python 3.9

(flick_env) G:\div_code\flick_env\flickr_scraper (master)
λ python flickr_scraper.py --search "bees" --n 10 --download
0/10 https://live.staticflickr.com/5537/14142817779_8786627929_o.jpg
1/10 https://live.staticflickr.com/829/41747732682_f4f10ec204_o.jpg
2/10 https://live.staticflickr.com/1662/23809746334_c22950a054_o.jpg
3/10 https://live.staticflickr.com/4094/4822128168_415b5ce1e4_o.jpg
4/10 https://farm6.staticflickr.com/5511/12638717365_7643b6e19a_b.jpg
5/10 https://live.staticflickr.com/961/27921370568_0795b91dfb_o.jpg
6/10 https://farm2.staticflickr.com/1646/26540040015_54f071db32_b.jpg
7/10 https://farm8.staticflickr.com/7377/26868463353_6da2da165d_b.jpg
8/10 https://farm8.staticflickr.com/7595/17187249975_b1ccddea5f_b.jpg
9/10 https://farm2.staticflickr.com/1578/26186589965_678bd3c5a4_b.jpg
beautytasara27 commented 2 years ago

Hi i did help with someone with this error on python-forum.io First show how to run Python 3.8 in environment with py(no need to downgrade)

# Make environment with Python 3.8 
G:\div_code\py -3.8 -m venv flick38_env  

Then i looked at error. In core.py line 690.

#photoset = rsp.getchildren()[0]  
photoset = list(rsp)[0] # Fix for Python 3.9

Test with Python 3.9

(flick_env) G:\div_code\flick_env\flickr_scraper (master)
λ python flickr_scraper.py --search "bees" --n 10 --download
0/10 https://live.staticflickr.com/5537/14142817779_8786627929_o.jpg
1/10 https://live.staticflickr.com/829/41747732682_f4f10ec204_o.jpg
2/10 https://live.staticflickr.com/1662/23809746334_c22950a054_o.jpg
3/10 https://live.staticflickr.com/4094/4822128168_415b5ce1e4_o.jpg
4/10 https://farm6.staticflickr.com/5511/12638717365_7643b6e19a_b.jpg
5/10 https://live.staticflickr.com/961/27921370568_0795b91dfb_o.jpg
6/10 https://farm2.staticflickr.com/1646/26540040015_54f071db32_b.jpg
7/10 https://farm8.staticflickr.com/7377/26868463353_6da2da165d_b.jpg
8/10 https://farm8.staticflickr.com/7595/17187249975_b1ccddea5f_b.jpg
9/10 https://farm2.staticflickr.com/1578/26186589965_678bd3c5a4_b.jpg

thank you.. you saved me

yx135790 commented 2 years ago

Hi i did help with someone with this error on python-forum.io First show how to run Python 3.8 in environment with py(no need to downgrade)

# Make environment with Python 3.8 
G:\div_code\py -3.8 -m venv flick38_env  

Then i looked at error. In core.py line 690.

#photoset = rsp.getchildren()[0]  
photoset = list(rsp)[0] # Fix for Python 3.9

Test with Python 3.9

(flick_env) G:\div_code\flick_env\flickr_scraper (master)
λ python flickr_scraper.py --search "bees" --n 10 --download
0/10 https://live.staticflickr.com/5537/14142817779_8786627929_o.jpg
1/10 https://live.staticflickr.com/829/41747732682_f4f10ec204_o.jpg
2/10 https://live.staticflickr.com/1662/23809746334_c22950a054_o.jpg
3/10 https://live.staticflickr.com/4094/4822128168_415b5ce1e4_o.jpg
4/10 https://farm6.staticflickr.com/5511/12638717365_7643b6e19a_b.jpg
5/10 https://live.staticflickr.com/961/27921370568_0795b91dfb_o.jpg
6/10 https://farm2.staticflickr.com/1646/26540040015_54f071db32_b.jpg
7/10 https://farm8.staticflickr.com/7377/26868463353_6da2da165d_b.jpg
8/10 https://farm8.staticflickr.com/7595/17187249975_b1ccddea5f_b.jpg
9/10 https://farm2.staticflickr.com/1578/26186589965_678bd3c5a4_b.jpg

thank you.. you saved me

worked for me ,thanks

sinhakrishnendu commented 2 years ago

@beautytasara27 you save me, thank you so much.