Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('simple_html_dom.php');
- $page = $_GET['page'];
- $html = file_get_html('http://www.hdvietnam.com/diendan/content.php?page=' . $page);
- $response = array();
- $posts = $html->find("div.fullwidth");
- foreach($posts as $post) {
- if($post->find(".leftcol") != null) {
- $link = $post->find(".leftcol .title .article_preview a", 0);
- $title = $link->find("span", 0);
- $content = $post->find(".leftcol div[class=cms_article_txt_content postcontainer]", 0);
- $img = cleanImg($post, ".leftcol .cms_article_preview_image");
- $response[] = array(
- 'Title' => str_replace(" ", "", strip_tags($title->innertext)),
- 'Link' => $link->href,
- 'Image' => $img,
- 'Content' => $content->innertext
- );
- }
- if($post->find(".rightcol") != null) {
- $link = $post->find(".rightcol .title .article_preview a", 0);
- $title = $link->find("span", 0);
- $content = $post->find(".rightcol div[class=cms_article_txt_content postcontainer]", 0);
- $img = cleanImg($post, ".rightcol .cms_article_preview_image");
- $response[] = array(
- 'Title' => str_replace(" ", "", strip_tags($title->innertext)),
- 'Link' => $link->href,
- 'Image' => $img,
- 'Content' => $content->innertext
- );
- }
- }
- header('Content-Type: application/json');
- echo json_encode(array('MangTin' => $response));
- function cleanImg($post, $class) {
- $img = $post->find($class, 0)->style;
- $img = str_replace("')", "", $img);
- $img = str_replace("background-image: url('", "", $img);
- return $img;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement