I want to extract a URL from a remote PHP response. My current code gets the link variable response, but how can I only a grab the first line of the response, which in this case is a URL?
URL to look in first line of PHP response in link variable:
http://test.awebsite.com/1.m3u8?token=454766879809809
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()
Full PHP response using print link
:
10:01:08 T:7688 NOTICE:
http://test.awebsite.com/1.m3u8?token=454766879809809
<!-- Start -->
<script type="text/javascript" src="http://1.js"></script>
<script type="text/javascript" src="http://1.js"></script>
<script type="text/javascript" src="http://3.js"></script>
<noscript><br><center><font color='#000000' face='Verdana' style='font-size: 11px; background-color:#FFFFFF'><a target='_blank' href='http://www.ads.com'><font color='#000000'>ads</font></a></font></center></noscript>
<!-- End -->