Ignore:
Timestamp:
May 5, 2019, 5:17:06 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Application made using classes System and Application.
  • Modified: Used Common package for better code reuse.
  • Modified: Application made modular. Web sections converted to application modules. They will register pages in main application object.
Location:
trunk/Modules
Files:
2 added
1 edited
1 moved

Legend:

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

    r32 r37  
    55  function Import()
    66  {
    7     parent::Import();
     7    $Output = parent::Import();
    88    $Content = file_get_contents($this->URL);
    9     $BlockStart = 'Tanec ...</h1 class=\'nadpis\'>';
    10     $BlockEnd = '<!--';
     9    $BlockStart = '<h1>Tanec ... : Seznamka</h1>';
     10    $BlockEnd = '<h2>Doporučujeme</h2>';
    1111    //echo($Content);
    1212    $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
    1313    if ($Content == '')
    1414    {
    15       echo('Main block not isolated.</br>');
    16       return;
     15      $Output .= 'Main block not isolated.</br>';
     16      return $Output;
    1717    }
    1818
    19     $ItemStart = '<div class=\'inztop\'>';
     19    $ItemStart = '<div class=\'col-xs-12\'>';
    2020    $ItemEnd = 'Odpovědět</a></div></div></div>';
    2121    while (strpos($Content, $ItemStart) !== false)
    2222    {
    2323      $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
     24      if ($Item == '') break;
    2425      $MeetItem = new MeetItem();
    2526      //$MeetItem->Image = trim(GetTextBetween($Item, '<div', '</div>'));
    26       if (strpos($Item, "return false\" class='") !== false)
    27       {
    28         $MeetItem->Gender = trim(GetTextBetween($Item, "return false\" class='", "'"));
    29       } else
    30       {
    31         $MeetItem->Gender = trim(GetTextBetween($Item, '<span class="ipoh ', '"'));
    32       }
     27      $MeetItem->Gender = trim(GetTextBetween($Item, "<span class=\"ipoh ", "\""));
    3328      if ($MeetItem->Gender == 'zena') $MeetItem->Gender = Gender::Female;
    34       else if ($MeetItem->Gender == 'muz') $MeetItem->Gender = Gender::Male;
    35       else $MeetItem->Gender = Gender::Undefined;   
     29        else if ($MeetItem->Gender == 'muz') $MeetItem->Gender = Gender::Male;
     30        else $MeetItem->Gender = Gender::Undefined;   
    3631      $MeetItem->Name = trim(GetTextBetween($Item, '>', '</span>'));
    3732      $MeetItem->Name = trim(strip_tags($MeetItem->Name));
    38       $Category = trim(GetTextBetween($Item, ' rel="nofollow">', '</a></span>'));
    39       $MeetItem->Age = trim(GetTextBetween($Item, ' rel="nofollow">', '</a></span>'));
     33      $Category = trim(GetTextBetween($Item, '" >', '</a>'));
     34      $MeetItem->Age = trim(GetTextBetween($Item, '" >', '</a>'));
    4035      $MeetItem->Age = trim(str_replace('let', '', $MeetItem->Age));
    41       $MeetItem->Location = trim(GetTextBetween($Item, ' rel="nofollow">', '</a></span>'));
    42       $MeetItem->Time = HumanDateToTime(trim(GetTextBetween($Item, '> </a>', '</span>')));
    43       $MeetItem->Message = trim(strip_tags(GetTextBetween($Item, 'margin-top:10px;\'>', '</div>')));
     36      $MeetItem->Location = trim(GetTextBetween($Item, '" >', '</a>'));
     37      $MeetItem->Time = trim(GetTextBetween($Item, 'TOP</a> &nbsp;', '</span>'));
     38      if ($MeetItem->Time == 'Včera') $MeetItem->Time = HumanDate(time() - 60*60*24);
     39        else if ($MeetItem->Time == 'Dnes') $MeetItem->Time = HumanDate(time());     
     40      $MeetItem->Time = HumanDateToTime($MeetItem->Time);
     41      $MeetItem->Message = trim(strip_tags(GetTextBetween($Item, '<p>', '</p>')));
    4442      $MeetItem->Link = GetTextBetween($Item, "<a href='", "'");
    4543      while (substr($MeetItem->Link, 0, 3) == '../')
     
    5452      $this->AddedCount += $MeetItem->AddIfNotExist();
    5553    }
     54    return $Output;
    5655  }
    5756}
Note: See TracChangeset for help on using the changeset viewer.