What would be the PHP equivalent to this code, I have tried curl but am unable to get it to work
import urllib2,urllib,re
url=' Delete me'
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=lemon.read()
response.close()
match=re.compile('Delete me 2').findall(link)
print match
Ok my code now looks like this
<?php
$url = "url";
$homepage = file_get_contents($url);
print $homepage
?>
in python I would now find the strings I need using something like this
match=re.compile('src="(.+?)" border="0" /></td>\n <td class="namewidth"><a title=".+?" href="(.+?)">(.+?)</a>').findall(link)
(.+?) being the unknown what is the equivalent to this in php?
Have you just tried file_get_contents()? It doesn't have the power of curl but if you just need to pull a URL it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.