Assembla home | Assembla project page
 
Show
Ignore:
Timestamp:
07/02/08 02:55:37 (5 months ago)
Author:
tobias382
Message:

Fixes #41 - Acronym plugin was modified to update the host and web scraping logic (thanks caseyw)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Acronym.php

    r255 r259  
    139139                                                "Accept-Language: en-us,en;q=0.8\r\n". 
    140140                                                "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n". 
    141                                                 "Referer: http://www.acronymfinder.com/\r\n", 
     141                                                "Referer: http://acronyms.thefreedictionary.com/\r\n", 
    142142                ) 
    143143            ); 
    144144            $context = stream_context_create($opts); 
    145             $url = 'http://www.acronymfinder.com/af-query.asp?Acronym=' . urlencode($acronym) . '&Find=find&string=exact'
     145            $url = 'http://acronyms.thefreedictionary.com/' . urlencode($acronym)
    146146            $contents = @file_get_contents($url, false, $context); 
    147147 
    148148                        if (empty ($contents) || 
    149                 strpos($contents, 'no abbreviation matches') !== false || 
    150                 strpos($contents, 'has exceeded the daily query limit') !== false) { 
     149                strpos($contents, 'Word not found') !== false) { 
    151150                $this->randomAction($source); 
    152151                return; 
     
    156155 
    157156                do { 
    158                     $count = preg_match('/<td width="65%"[^>]+>([^<]+)</i', $contents, $match, PREG_OFFSET_CAPTURE, $offset); 
     157                    $count = preg_match('/<td>([^<]+)</i', $contents, $match, PREG_OFFSET_CAPTURE, $offset); 
    159158                    if ($count == 1) { 
    160159                        $matches[] = html_entity_decode($match[1][0]);