public function metawebsite($w_id = '', $wp_id = '') { if ($this->uri->total_segments() == 3) { $all_websites = $this->model_front->get_all_websites(); $row = $all_websites->row($w_id); $parser = new WebsiteParser($row->w_url_rw); $meta_tags = $parser->getMetaTags(true); $meta_title = $parser->getTitle(true); $meta_description = ""; foreach ($meta_tags as $meta_tag) { if ($meta_tag[0] == 'description') { $meta_description = $meta_tag[1]; } } $datatable = array(0 => $row->w_title, 1 => '<a href="https://www.google.com/search?q=info:' . $row->w_url_rw . '" target="_blank">' . $row->w_url_rw . '</a>', 2 => html_entity_decode($meta_title, ENT_QUOTES), 3 => html_entity_decode($meta_description, ENT_QUOTES), 4 => '<a href="' . site_url('seo-websites/' . $row->w_id) . '" class="viewdata btn btn-success btn-xs" data-toggle="modal"><span class="fa fa-eye"></a>'); echo json_encode($datatable, JSON_FORCE_OBJECT); } elseif ($this->uri->total_segments() == 4) { $row = $this->model_front->get_website($w_id)->row(); $parser = new WebsiteParser($this->arr[$wp_id]); $meta_tags = $parser->getMetaTags(true); $meta_title = $parser->getTitle(true); $meta_description = ""; foreach ($meta_tags as $meta_tag) { if ($meta_tag[0] == 'description') { $meta_description = $meta_tag[1]; } } $datatable = array(0 => $row->w_title, 1 => '<a href="https://www.google.com/search?q=info:' . $this->arr[$wp_id] . '" target="_blank">' . $this->arr[$wp_id] . '</a>', 2 => html_entity_decode($meta_title, ENT_QUOTES), 3 => html_entity_decode($meta_description, ENT_QUOTES)); echo json_encode($datatable, JSON_FORCE_OBJECT); } }
public function testNormalSite() { $result = WebsiteParser::parse("http://normal.site"); $this->assertFalse($result->isError()); $this->assertFalse($result->hasImage()); $this->assertEquals("Normal Site", $result->Title); $this->assertEquals("The description", $result->Description); }
/** * @param SS_HTTPRequest $request * @return string */ public function run($request) { $target = urldecode($request->getVar('target')); if (!$target) { return "Please provide a target as GET param."; } $parsedData = WebsiteParser::parse($target); var_dump($parsedData); }
<?php include 'website_parser.php'; //Instance of WebsiteParser $parser = new WebsiteParser('http://morshed-alam.com/'); //Get all hyper links $links = $parser->getHrefLinks(); //Get all image sources $images = $parser->getImageSources(); echo "<pre>"; print_r($links); echo "<br />"; print_r($images); echo "</pre>"; /** * ========================================== * Sample Output * ========================================== Array ( [0] => Array ( [0] => https://github.com/joliss/jquery-ui-rails [1] => jquery-ui-rails ) [1] => Array ( [0] => http://gembundler.com/rails23.html [1] => Click here )
<?php include 'website_parser.php'; $links = $images = array(); $default_check = 'checked'; $href = isset($_GET['href']) ? 1 : 0; $image = isset($_GET['image']) ? 1 : 0; $meta = isset($_GET['meta']) ? 1 : 0; $target_url = isset($_GET['target_url']) ? $_GET['target_url'] : ''; $link_type = isset($_GET['link_type']) ? $_GET['link_type'] : 'all'; $parser = new WebsiteParser($target_url, $link_type); if (isset($_GET['target_url'])) { $default_check = ''; $title = $parser->getTitle(true); if ($href) { $links = $parser->getHrefLinks(false); } if ($image) { $images = $parser->getImageSources(); } if ($meta) { $meta_tags = $parser->getMetaTags(); } } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Extract Urls</title>