Note that there are some explanatory texts on larger screens.

plurals
  1. POPreg_match_all not stopping where it should be
    text
    copied!<h2>Update Yahoo error</h2> <p>Ok, so I got it all working, but the preg_match_all wont work towards Yahoo. If you take a look at: <a href="http://se.search.yahoo.com/search?p=random&amp;toggle=1&amp;cop=mss&amp;ei=UTF-8&amp;fr=yfp-t" rel="nofollow">http://se.search.yahoo.com/search?p=random&amp;toggle=1&amp;cop=mss&amp;ei=UTF-8&amp;fr=yfp-t</a> then you can see that in their html, they have <code>&lt;span class="url" id="something random"&gt; the actual link &lt;/span&gt;</code> But when I try to preg_match_all, I wont get any result.</p> <pre><code>preg_match_all('#&lt;span class="url" id="(.*)"&gt;(.+?)&lt;/span&gt;#si', $urlContents[2], $yahoo); </code></pre> <p>Anyone got an idea?</p> <h2>End of update</h2> <p>I'm trying to preg_match_all the results i get from Google using a cURL curl_multi_getcontent method.</p> <p>I have succeeded to fetch the site and so, but when I'm trying to get the result of the links, it just takes too much.</p> <p>I'm currently using: <code>preg_match_all('#&lt;cite&gt;(.+)&lt;/cite&gt;#si', $urlContents[0], $links);</code></p> <p>And that starts where it should be, but it doesn't stop, it just keeps going. Check the HTML at <code>www.google.com/search?q=random</code> for example and you will see that all links start with and ends with .</p> <p>Could someone possible help me with how I should retreive this information? I only need the actual link address to each result.</p> <h2>Update Entire PHP Script</h2> <pre><code>public function multiSearch($question) { $sites['google'] = "http://www.google.com/search?q={$question}&amp;gl=sv"; $sites['bing'] = "http://www.bing.com/search?q={$question}"; $sites['yahoo'] = "http://se.search.yahoo.com/search?p={$question}"; $urlHandler = array(); foreach($sites as $site) { $handler = curl_init(); curl_setopt($handler, CURLOPT_URL, $site); curl_setopt($handler, CURLOPT_HEADER, 0); curl_setopt($handler, CURLOPT_RETURNTRANSFER, 1); array_push($urlHandler, $handler); } $multiHandler = curl_multi_init(); foreach($urlHandler as $key =&gt; $url) { curl_multi_add_handle($multiHandler, $url); } $running = null; do { curl_multi_exec($multiHandler, $running); } while($running &gt; 0); $urlContents = array(); foreach($urlHandler as $key =&gt; $url) { $urlContents[$key] = curl_multi_getcontent($url); } foreach($urlHandler as $key =&gt; $url) { curl_multi_remove_handle($multiHandler, $url); } foreach($urlContents as $urlContent) { preg_match_all('/&lt;li class="g"&gt;(.*?)&lt;\/li&gt;/si', $urlContent, $matches); //$this-&gt;view_data['results'][] = "Random"; } preg_match_all('#&lt;div id="search"(.*)&lt;/ol&gt;&lt;/div&gt;#i', $urlContents[0], $match); preg_match_all('#&lt;cite&gt;(.+)&lt;/cite&gt;#si', $urlContents[0], $links); var_dump($links); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload