B
B
BonBon Slick2016-09-02 14:00:56
PHP
BonBon Slick, 2016-09-02 14:00:56

How to parse titles of all links on a page?

I have a parser that pulls specific information from the 1st page of a product.

<form action="" method="post">
  <input type="url" name="pase_url" placeholder="Parse URL">
  <button type="submit" name="parse" >Parse Link!</button>
</form>
<?php
// Parse function, to sanitize parsing data
function parse( $param_1, $param_2, $param_3 ){
  $html_tags_1 = strpos( $param_1, $param_2 );
  if( $html_tags_1 === false ){
    return 0;
  } 
  $html_tags_2 =  substr( $param_1, $html_tags_1 );
  return strip_tags( substr ($html_tags_2, 0, strpos ( $html_tags_2, $param_3 )));
}
// Parse data
if( isset($_POST['parse']) ){
  $parse_url = $_POST['pase_url'];
  $dom_data = file_get_contents( $parse_url );
  echo '<br>' . 'Title: ' . parse($dom_data, '<title>', '</title>');
}  
?>

Now you need to go up a level, to the sub-categories section, parse all links to products, and take their titles from them (I’ll figure out the rest myself).
Please tell me how to do this?
To be a little more specific, there is an array of links, you need to go into each of them, and pull out the necessary information.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Grabko, 2016-09-02
@BonBonSlick

loop + standard library for working with dom

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question