S
S
Suxoi2016-10-18 18:35:02
PHP
Suxoi, 2016-10-18 18:35:02

How to parse structured data?

There is a site on which the data is laid out in tags with the same classes, you need to get and insert into the database
There are a lot of such blocks, you need to be like this
"Name" : "Enterprise Leasing Company, Executive Leasing Company, Domain company"

div class="row">
  <div class="col-md-6 col-sm-6 col-xs-12"><strong>Name:</strong></div>
  <div class="col-md-6 col-sm-6 col-xs-12">
        <ul><li>Enterprise Leasing Company</li>
              <li>Executive Leasing Company</ul>
       </div>
        <div class="col-md-6 col-sm-6 col-xs-12">Domain company</div>
</div>

wrote a few lines, but I don’t like how it works, and I want some lines to be wrapped, and not written in solid text
$company_value = $xpath->query( '//div[@class="col-md-6 col-sm-6 col-xs-12"]' );

  foreach( $company_value as $tags ) {
    $value = str_replace( [ "\t", "\n", ":" ], '', $tags->nodeValue );
    $value = str_replace( 'comwww', 'com , www' , $value);
    $data_value [] = $value;
  }
  $data_res = [ ];
  for( $i = 0; $i < count( $data_value ); $i++ ) {
    $data_value[ $i ] = mb_strtolower( str_replace( [ " ", "(", ")", "/" ], '', $data_value[ $i ] ) );
    $data_res [ $data_value[ $i ] ] = $data_value[ $i + 1 ];
    $i = $i + 1;
  }
  $data = $data + $data_res;

  if( array_key_exists( 'websites', $data ) ) {
    $data [ 'website' ] = $data [ 'websites' ];
    unset( $data [ 'websites' ] );
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2016-10-18
@springimport

Try apist .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question