I have a string variable called link that returns data from a remote site. How i can parse data after equal sign(token=) ? For example i want to grab "234132421reafdfasdfsdfdsf3234423edfasfdsf" from following line.
file: "http://www.aaastreams.com/playlist.m3u8?token=234132421reafdfasdfsdfdsf3234423edfasfdsf"
});
python code:
req = urllib2.Request('http://www.somesite.com/test.php')
req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0')
response = urllib2.urlopen(req)
link = response.read()
sample response value from "print link;":
.......rest of response
<script>
jwplayer("container").setup({
width:700,
height:220,
primary: "hls",
title:"streams",
autostart:true,
image: "./1.jpg",
file: "http://www.aaastreams.com/playlist.m3u8?token=234132421reafdfasdfsdfdsf3234423edfasfdsf"
});
jwplayer().onError(function(){
jwplayer().load({file:"http://www.aaa.com/jwplayer/ads.mp4",image:"http://aaa.com/2.png"});
jwplayer().play();
});
</script>
.......rest of response
After trying different solution i came up with easiest way to solve this problem:
tokenValue = re.search('token=(.*)"', link)
print tokenValue.group(1);