I'm trying to write a script that will search a page for mp3 files, and download the first one. All is fine, but when I'm finding the links the first two are not mp3 files. At the moment I'm doing:

for link in page.findAll('a')[:3]:
   f.write(link.get('href'))

This finds the first 3 results, the third of which is the first mp3 file on the page. My question is, instead of finding the first three links, how can i find JUST the third? I need to do this so I can write it to a file and let my downloader pick it up.

Thanks in advance, Tom.

Recommended Answers

All 2 Replies

page.findAll('a')[2].get('href')

Thanks Tony, works a treat.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.