Changeset 11


Ignore:
Timestamp:
Aug 26, 2018, 8:53:55 PM (6 years ago)
Author:
chronos
Message:
  • Fixed: Updated parsing of Astra website.
  • Fixed: Correctly parse Amblar date.
  • Added: Allow to update only one meet source by specified id.
  • Added: Show RSS link with RSS icon under meet table.
Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Import/Amblar.php

    r10 r11  
    2828  function Import()
    2929  {
    30     echo('Parsing '.$this->Name.'...</br>');
     30    parent::Import();
    3131    $Content = file_get_contents($this->URL);
    3232
     
    5353        else $MeetItem->Gender = Gender::Male;
    5454      $MeetItem->Name = trim(GetTextBetween($Item, '<span class="dwqa-author">', '</span>'));
    55       $MeetItem->Date = HumanDateToTime(trim(GetTextBetween($Item, '<span class="dwqa-date">', '</span>')));
     55      $MeetItem->Date = trim(GetTextBetween($Item, '<span class="dwqa-date">', '</span>'));
     56      if ($MeetItem->Date == 'před 1 dní') $MeetItem->Date = strtotime("-1 days");
     57        else $MeetItem->Date = HumanDateToTime($MeetItem->Date);
    5658      $MeetItem->Email = '';
    5759      $MeetItem->Message = '';
     
    6466      $MeetItem->Source = $this->Id;
    6567      $this->ImportItem($MeetItem);
    66       $MeetItem->AddIfNotExist();
     68      $this->AddedCount += $MeetItem->AddIfNotExist();
    6769    }
    6870  }
  • trunk/Import/AstraPraha.php

    r8 r11  
    55  function Import()
    66  {
    7     echo('Parsing '.$this->Name.'...</br>');
     7    parent::Import();
    88    $Content = file_get_contents($this->URL);
    9     $Content = RemoveHtmlComments($Content);
    109
    11     $BlockStart = '----------------------------------------------';
    12     $BlockEnd = '<script type="text/javascript"';
     10    $BlockStart = '<h2>Tanečního partnera hledají:</h2>';
     11    $BlockEnd = '<hr />';
    1312    $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
    1413    if ($Content == '')
     
    1817    }
    1918
    20     $ItemStart = '</div><h2></h2>';
    21     $ItemEnd = '<div class="clearer"></div><div class="clearer">';
     19    $ItemStart = '<p class=\'dating-date\'>';
     20    $ItemEnd = '<hr class=\'dating-spacer\' />';
    2221    while (strpos($Content, $ItemStart) !== false)
    2322    {
    2423      $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
    2524      $MeetItem = new MeetItem();
    26       $MeetItem->Gender = trim(GetTextBetween($Item, ');"><u>', '</u>'));
     25      $MeetItem->Date = trim(GetTextBetween($Item, 'Vloženo:', '</p>'));
     26      $MeetItem->Date = HumanDateToTime($MeetItem->Date);
     27
     28      $MeetItem->Gender = trim(GetTextBetween($Item, '<h3 class=\'dating-heading\'>', '</h3>'));
    2729      if ($MeetItem->Gender == 'Hledám partnerku') $MeetItem->Gender = Gender::Male;
    2830        else $MeetItem->Gender = Gender::Female;
    29       $End = '<em>';
    30       $MeetItem->Message = trim(substr($Item, 0, strpos($Item, $End)));
    31       $Item = substr($Item, strpos($Item, $End) + strlen($End));
    32       $MeetItem->Message = trim(strip_tags($MeetItem->Message));
    33       $MeetItem->Date = trim(GetTextBetween($Item, 'datum vložení', '</em>'));
    34       if (substr($MeetItem->Date, 0, 1) == ':')
    35         $MeetItem->Date = trim(substr($MeetItem->Date, 1));
    36       $MeetItem->Date = HumanDateToTime($MeetItem->Date);
    37       $MeetItem->Email = GetEmailFromText($MeetItem->Message);
     31      $MeetItem->Message = trim(GetTextBetween($Item, '<p class=\'last-element\'>', '</p>'));
     32      $MeetItem->Email = trim(GetTextBetween($Item, 'class="nowrap text-link">', '</a>'));
    3833      $MeetItem->Name = '';
    3934      $MeetItem->Age = GetAgeFromText($MeetItem->Message);
     
    4439      $MeetItem->Database = $this->Database;
    4540      $MeetItem->Source = $this->Id;
    46       $MeetItem->AddIfNotExist();
     41      $this->AddedCount += $MeetItem->AddIfNotExist();
    4742    }
    4843  }
  • trunk/Import/SalsaDance.php

    r8 r11  
    55  function Import()
    66  {
    7     echo('Parsing '.$this->Name.'...</br>');
     7    parent::Import();
    88    $Content = file_get_contents($this->URL);
    99    $BlockStart = '<ul class="comments">';
     
    4040      $MeetItem->Database = $this->Database;
    4141      $MeetItem->Source = $this->Id;
    42       //print_r($MeetItem);
    43       $MeetItem->AddIfNotExist();
     42      $this->AddedCount += $MeetItem->AddIfNotExist();
    4443    }
    4544  }
  • trunk/Import/Seznamka.php

    r8 r11  
    55  function Import()
    66  {
    7     echo('Parsing '.$this->Name.'...</br>');
     7    parent::Import();
    88    $Content = file_get_contents($this->URL);
    99    $BlockStart = 'Tanec ...</h1 class=\'nadpis\'>';
     
    4242      $MeetItem->Database = $this->Database;
    4343      $MeetItem->Source = $this->Id;
    44       //unset($MeetItem->Database);
    45       //print_r($MeetItem);
    46       $MeetItem->AddIfNotExist();
     44      $this->AddedCount += $MeetItem->AddIfNotExist();
    4745    }
    4846  }
  • trunk/Import/TanecniSkola.php

    r8 r11  
    2626    );
    2727
    28     echo('Parsing '.$this->Name.'...</br>');
     28    parent::Import();
    2929    $Content = file_get_contents($this->URL);
    3030
     
    8585        $MeetItem->Database = $this->Database;
    8686        $MeetItem->Source = $this->Id;
    87         $MeetItem->AddIfNotExist();
     87        $this->AddedCount += $MeetItem->AddIfNotExist();
    8888      }
    8989    }
  • trunk/Import/Vavruska.php

    r8 r11  
    55  function Import()
    66  {
    7     echo('Parsing '.$this->Name.'...</br>');
     7    parent::Import();
    88    $Content = file_get_contents($this->URL);
    99
     
    3939      $MeetItem->Database = $this->Database;
    4040      $MeetItem->Source = $this->Id;
    41       $MeetItem->AddIfNotExist();
     41      $this->AddedCount += $MeetItem->AddIfNotExist();
    4242    }
    4343  }
  • trunk/Meet.php

    r10 r11  
    145145
    146146      $Result = trim(substr($Result, 0, $End + 1));
    147       break;
     147      if (is_numeric($Result)) break;
    148148    } else break;
    149149  }
     
    153153function GetAgeFromText($Text)
    154154{
     155  $Text = strtolower($Text);
    155156  $Result = GetNumberBeforeText($Text, 'let');
    156   if ($Result == '') $Result = GetNumberAfterText($Text, 'Je mi');
     157  if ($Result == '') $Result = GetNumberAfterText($Text, 'je mi');
     158  if ($Result == '') $Result = GetNumberAfterText($Text, 'jsem');
    157159  if ($Result == '') $Result = GetNumberAfterText($Text, 'čerstvých');
    158160  if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[0];
     
    162164function GetHeightFromText($Text)
    163165{
     166  $Text = strtolower($Text);
    164167  $Result = GetNumberBeforeText($Text, 'cm');
    165168  if ($Result == '') $Result = GetNumberAfterText($Text, 'měřím');
     169  if ($Result == '') $Result = GetNumberAfterText($Text, 'merim');
    166170  if ($Result == '') $Result = GetNumberBeforeText($Text, 'bez podpatků');
    167171  if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[1];
     
    171175function GetWeightFromText($Text)
    172176{
     177  $Text = strtolower($Text);
    173178  $Result = GetNumberBeforeText($Text, 'kg');
    174179  if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[2];
     
    233238  public $Database;
    234239
    235   function ParseAll()
    236   {
    237     $DbResult = $this->Database->select('MeetSource', '*');
     240  function Parse($Id = null)
     241  {
     242    if (($Id != null) and is_numeric($Id)) $Where = 'Id='.$Id;
     243      else $Where = '1';
     244    $DbResult = $this->Database->select('MeetSource', '*', $Where);
    238245    while ($DbRow = $DbResult->fetch_assoc())
    239246    {
     
    267274  public $Id;
    268275  public $Database;
     276
     277  function Import()
     278  {
     279    $this->AddedCount = 0;
     280    echo('Parsing '.$this->Name.' ('.$this->Id.')...</br>');
     281  }
    269282}
    270283
     
    310323        'Link' => $this->Link,
    311324      ));
    312     }
    313   }
    314 }
     325      $Result = 1;
     326    } else $Result = 0;
     327    return($Result);
     328  }
     329}
  • trunk/index.php

    r9 r11  
    111111    $MeetSources = new MeetSources();
    112112    $MeetSources->Database = $this->Database;
    113     $MeetSources->ParseAll();
     113    if (array_key_exists('i', $_GET)) $MeetSources->Parse($_GET['i']);
     114      else $MeetSources->Parse();
    114115  }
    115116
     
    267268    $Output .= $PageList['Output'];
    268269    $Output .= '</div>';
     270    $Output .= '<a href="'.$this->Link('/seznamka-rss/').'"><img src="'.$this->Link('/images/rss20.png').'" alt="rss20"/></a><br/>';
    269271
    270272    return($Output);
     
    324326      '</head><body>';
    325327    $Output .= $Content;
    326     $Output .= '<div class="footer">Kontakt: <a href="mailto:'.$Config['Contact'].'">'.$Config['Contact'].'</a> '.
     328    $Output .= '<br/><div class="footer">Kontakt: <a href="mailto:'.$Config['Contact'].'">'.$Config['Contact'].'</a> '.
    327329       '<a href="https://svn.zdechov.net/trac/tanec/">Zdrojový kód</a></div>';
    328330    $Output .= '</body></html>';
Note: See TracChangeset for help on using the changeset viewer.