Changeset 42 for trunk


Ignore:
Timestamp:
Sep 17, 2019, 10:13:33 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Update Vavruska import after remote website change.
Location:
trunk/Modules/Meet
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Meet/Import/Vavruska.php

    r37 r42  
    88    $Content = file_get_contents($this->URL);
    99
    10     $BlockStart = '<table class="seznamka">';
    11     $BlockEnd = '<hr class="welt_bottom" />';
     10    $BlockStart = '<h2 class="wow fadeIn">Aktuální inzeráty</h2>';
     11    $BlockEnd = '<div class="clearfix"></div>';
    1212    $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
    1313    if ($Content == '')
     
    1717    }
    1818
    19     $ItemStart = '<tr class="spc">';
    20     $ItemEnd = '</table>
    21                 </td></tr>';
     19    $ItemStart = '<div class="col-sm-12">';
     20    $ItemEnd = "</div>\n".
     21    '        </div>';
    2222    while (strpos($Content, $ItemStart) !== false)
    2323    {
     
    2525      $MeetItem = new MeetItem();
    2626
    27       $MeetItem->Time = MysqlDateTimeToTime(trim(GetTextBetween($Item, 'přidáno:', '</i>')));
    28       $MeetItem->Gender = trim(GetTextBetween($Item, '<img src=/design/', 'alt="avatar"'));
    29       if ($MeetItem->Gender == 'avatar_m_03.png') $MeetItem->Gender = Gender::Male;
    30         else $MeetItem->Gender = Gender::Female;
    31       $MeetItem->Name = trim(GetTextBetween($Item, 'Jméno:</td><td>', '</td>'));
    32       $MeetItem->Email = DecodeHtmlEnt(trim(GetTextBetween($Item, 'Kontakt:</td><td>', '</td>')));
    33       $MeetItem->Message = trim(GetTextBetween($Item, 'Text:</td><td>', '</td>'));
     27      $MeetItem->Gender = GetTextBetween($Item, '<h5 class="', '"');
     28      if ($MeetItem->Gender == 'muz') $MeetItem->Gender = Gender::Male;
     29      else if ($MeetItem->Gender == 'zena') $MeetItem->Gender = Gender::Female;
     30      else $MeetItem->Gender = Gender::Undefined;
     31      $MeetItem->Name = GetTextBetween($Item, '>', '<');
     32      $MeetItem->Email = GetTextBetween($Item, '<p>', '</p>');
     33      $MeetItem->Time = HumanDateToTime(trim(GetTextBetween($Item, '<p class="pridano">Přidáno:', '</p>')));
     34      $MeetItem->Message = trim(GetTextBetween($Item, '<p class="text">', '</p>'));
    3435      $MeetItem->Phone = '';
    3536      $MeetItem->Height = GetHeightFromText($MeetItem->Message);
     
    3940      $MeetItem->Database = $this->Database;
    4041      $MeetItem->Source = $this->Id;
     42      if ($MeetItem->Name == 'Nový Design Inzerátů') continue;
    4143      $this->AddedCount += $MeetItem->AddIfNotExist();
    4244    }
  • trunk/Modules/Meet/Meet.php

    r41 r42  
    169169  $Text = strtolower($Text);
    170170  $Result = GetNumberAfterText($Text, 'je mi');
    171   if ($Result == '') $Result = GetNumberAfterText($Text, 'jsem');
     171  if ($Result == '') $Result = GetNumberBeforeText($Text, 'let');
    172172  if ($Result == '') $Result = GetNumberBeforeText($Text, 'rokov');
    173173  if ($Result == '') $Result = GetNumberBeforeText($Text, 'letou');
    174   if ($Result == '') $Result = GetNumberBeforeText($Text, 'let');
    175174  if ($Result == '') $Result = GetNumberAfterText($Text, 'čerstvých');
     175  if ($Result == '') {
     176    $Result = GetNumberAfterText($Text, 'jsem');
     177    if ($Result > 100) $Result = ''; // Age over 100 is probably not age but height
     178  }
    176179  if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[0];
    177180  if ($Result == '') {
     
    179182    if ($Year != '') $Result = date('Y', time()) - $Year;
    180183  }
     184  if ($Result == '') {
     185    $Year = GetNumberAfterText($Text, 'narozen roku');
     186    if ($Year != '') $Result = date('Y', time()) - $Year;
     187  }
    181188  return $Result;
    182189}
     
    184191function GetHeightFromText($Text)
    185192{
    186   $Text = strtolower($Text); 
     193  $Text = strtolower($Text);
    187194  $Result = GetNumberAfterText($Text, 'měřím');
    188195  if ($Result == '') $Result = GetNumberAfterText($Text, 'merim');
    189   if ($Result == '') $Result = GetNumberBeforeText($Text, 'cm'); 
     196  if ($Result == '') $Result = GetNumberAfterText($Text, 'výška');
     197  if ($Result == '') $Result = GetNumberBeforeText($Text, 'cm');
    190198  if ($Result == '') $Result = GetNumberBeforeText($Text, 'bez podpatků');
     199  if ($Result == '') {
     200    $Result = GetNumberAfterText($Text, 'jsem');
     201    if ($Result < 150) $Result = ''; // Height below 150 is probably not height but age
     202  }
    191203  if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[1];
    192204  return $Result;
     
    198210  $Result = GetNumberBeforeText($Text, 'kg');
    199211  if ($Result == '') $Result = GetNumberAfterText($Text, 'vážím');
     212  if ($Result == '') $Result = GetNumberAfterText($Text, 'váha');
    200213  if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[2];
    201214  return $Result;
     
    264277{
    265278  global $Locations;
    266  
     279
    267280  $Text = strtolower($Text);
    268281
     
    357370    if ($DbResult->num_rows == 0)
    358371    {
    359       if ($this->Age == '') $Age = null; 
     372      if ($this->Age == '') $Age = null;
    360373        else $Age = $this->Age;
    361       if ($this->Height == '') $Height = null; 
     374      if ($this->Height == '') $Height = null;
    362375        else $Height = $this->Height;
    363       if ($this->Weight == '') $Weight = null; 
     376      if ($this->Weight == '') $Weight = null;
    364377        else $Weight = $this->Weight;
    365378      $this->Database->insert('MeetItem', array(
Note: See TracChangeset for help on using the changeset viewer.