Answer the question
In order to leave comments, you need to log in
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>');
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question