I’m trying to extract the urls from a .htm source, that contains 3 other urls inside a java script code.I’m trying to use Hpple.
How to parse on the iPhone the URLs under ‘file’ on the .htm source code below:
<html>
<head>
<script type="text/javascript" src="http://mydomain/jwplayer/jwplayer.js"></script>
</head>
<body>
<div id='container'>Player should appear here</div>
<script type='text/javascript'>
jwplayer('container').setup({
'flashplayer': 'http://mydomain/directory1/jwplayer/player.swf',
'controlbar.position': 'bottom',
'controlbar.idlehide': 'false',
'width': '550',
'height': '300',
'autostart': 'true',
'icons': 'true',
'playlist': [{
'file': 'http://http://mydomain/directory1/english/audio1.m4a',
},{
'file': 'http://http://mydomain/directory1/english/audio2.m4a',
},{
'file': 'http://http://mydomain/directory1english/audio3.m4a',
}],
repeat: 'list'
});
</script>
</body>
</html>
The contents of the
<script>tag aren’t HTML, so hpple won’t be able to parse it. What you want to do is to use hpple to get the contents of the<script>tag:Then use a NSRegularExpression to get those URLs out of there.