I am making a search results page on my website, i am trying to make it detect when a company is searched and get a Wikipedia script from it.
But i only want it to show the code if the search is a company similar to google and bing
Google search for Microsoft showing information on companies.
i have the api setup to get the first paragraph. But now i need to detect if it is a business, get the images, and get the founders/ceos
here's the code i have so far
<div style='width:400px;float:right;border-radius:5px;border:1px solid black;margin:10px 20px;'>
<?php
$search = urlencode($search);
$url = 'http://en.wikipedia.org/w/api.php?action=parse&page='.$search.'&format=json&prop=text§ion=0';
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, "TestScript");
$c = curl_exec($ch);
$json = json_decode($c);
$content = $json->{'parse'}->{'text'}->{'*'};
?>
<div style='width:100px;height:100px;float:right;'>
<?php
//where i want the picture to display
?>
</div>
<div>
<?php
$pattern = '#<p>(.*)</p>#Us';
if(preg_match($pattern, $content, $matches)){
print clean(strip_tags($matches[1]));
}
?>
</div>
</div>
I've looked at the wikipedia API but i can't seem to find anything that shows if its in a section about companies or not, also crawling the page for images seems to be very laggy and unneeded. Also would using JavaScript be a better way of getting it then using php?