iTunes URLs look like the following:
http://itunes.apple.com/us/album/break-of-dawn/id472335316?ign-mpt=uo%3D
http://itunes.apple.com/us/app/monopoly-here-now-the-world/id299110947?mt=8
http://itunes.apple.com/es/app/revista-/id397781759?mt=8%3Futm_so%3Dtwitter
http://itunes.apple.com/app/id426698291&mt=8"
http://itunes.apple.com/us/album/respect-the-bull-single/id4899
http://itunes.apple.com/us/album/id6655669
How can I easily extract id number?
Example:
get_id("http://itunes.apple.com/us/album/brawn/id472335316?ign-mpt=uo")
#returns 472335316
import re
def get_id(toParse):
return re.search('id(\d+)', toParse).groups()[0]
I'll let you figure out error handling...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With