Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The code below works like a champ tested with your example data:</p> <pre><code>&lt;?php $urlarray = explode("|", $contents = file_get_contents('urls.txt')); $url = $urlarray[0]; $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $html = curl_exec($ch); $dom = new DOMDocument(); @$dom-&gt;loadHTML($html); $anchors = $dom-&gt;getElementsByTagName('a'); foreach($anchors as $element) { $title = $element-&gt;getAttribute('title'); $class = $element-&gt;getAttribute('class'); if($class == 'result_link') { $title = str_replace('Synonyms of ', '', $title); echo $title . "&lt;br /&gt;"; } } ?&gt; </code></pre> <p>ALMOST FORGOT: LETS NOW PUT IT IN A LOOP TO LOOP THROUGH ALL URLS:</p> <pre><code>&lt;?php $urlarray = explode("|", $contents = file_get_contents('urls.txt')); $url = $urlarray[0]; foreach($urlarray as $url) { if(!empty($url)) { $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,trim($url)); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $html = curl_exec($ch); $dom = new DOMDocument(); @$dom-&gt;loadHTML($html); $anchors = $dom-&gt;getElementsByTagName('a'); foreach($anchors as $element) { $title = $element-&gt;getAttribute('title'); $class = $element-&gt;getAttribute('class'); if($class == 'result_link') { $title = str_replace('Synonyms of ', '', $title); echo $title . "&lt;br /&gt;"; } } echo '&lt;hr /&gt;'; } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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