Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function file_get_contents_curl1($url) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
- }
- //The URL for the external content we want to pull
- $html = file_get_contents_curl1("https://external.url.com/subdir/");
- //parsing all content:
- $doc = new DOMDocument();
- @$doc->loadHTML($html);
- $content = $html;
- //The div that includes the content '<div id="divid">'
- $first_step = explode( '<div id="ide">' , $content );
- $second_step = explode("</div>" , $first_step[1] );
- //Do some magic with the URL
- $url2 = $second_step[0];
- $url3 = $second_step[8];
- $url4 = $second_step[16];
- $url5 = $second_step[24];
- $url6 = $second_step[32];
- $url7 = $second_step[40];
- $patterns = array(
- '#\./opening;jsessionid=.*\?#',
- '#<a href=#',
- '#span(.*?)>#'
- );
- $replaces = array(
- 'https://external.url.com/subdir/opening?',
- '<a target="_blank" href=',
- 'h1>'
- );
- //Print the final output
- ///Merge the result into one variable
- $final_output =
- '<div class="one">' .
- //'div 1' .
- preg_replace($patterns, $replaces, $url2) .
- $second_step[1] . /* Description -- NOTE: By commenting out this you need to change the H1 margin in the style declaration */
- $second_step[2] . /* From date */
- $second_step[3] . /* To date */
- $second_step[4] . /* Company */
- $second_step[5] . /* Employment condition (full-time/part-time) */
- $second_step[6] . /* Department */
- //$second_step[7] .
- //'<hr>' . /* Horizontal rule */
- '</div><div class="two">' .
- //'div 2' .
- preg_replace($patterns, $replaces, $url3) .
- $second_step[9] . /* Description -- NOTE: By commenting out this you need to change the H1 margin in the style declaration */
- $second_step[10] . /* From date */
- $second_step[11] . /* To date */
- $second_step[12] . /* Company */
- $second_step[13] . /* Employment condition (full-time/part-time) */
- $second_step[14] . /* Department */
- //$second_step[15] .
- //'<hr>' . /* Horizontal rule */
- '</div><div class="three">' .
- //'div 3' .
- preg_replace($patterns, $replaces, $url4) .
- $second_step[17] . /* Description -- NOTE: By commenting out this you need to change the H1 margin in the style declaration */
- $second_step[18] . /* From date */
- $second_step[19] . /* To date */
- $second_step[20] . /* Company */
- $second_step[21] . /* Employment condition (full-time/part-time) */
- $second_step[22] . /* Department */
- //$second_step[23] .
- //'<hr>' . /* Horizontal rule */
- '</div><div class="four">' .
- //'div 4' .
- preg_replace($patterns, $replaces, $url5) .
- $second_step[25] . /* Description -- NOTE: By commenting out this you need to change the H1 margin in the style declaration */
- $second_step[26] . /* From date */
- $second_step[27] . /* To date */
- $second_step[28] . /* Company */
- $second_step[29] . /* Employment condition (full-time/part-time) */
- $second_step[30] . /* Department */
- //$second_step[31] .
- //'<hr>' . /* Horizontal rule */
- '</div><div class="five">' .
- //'div 5' .
- preg_replace($patterns, $replaces, $url6) .
- $second_step[33] . /* Description -- NOTE: By commenting out this you need to change the H1 margin in the style declaration */
- $second_step[34] . /* From date */
- $second_step[35] . /* To date */
- $second_step[36] . /* Company */
- $second_step[37] . /* Employment condition (full-time/part-time) */
- $second_step[38] . /* Department */
- //$second_step[39] .
- //'<hr>' . /* Horizontal rule */
- '</div><div class="six">' .
- //'div 6' .
- preg_replace($patterns, $replaces, $url7) .
- $second_step[41] . /* Description -- NOTE: By commenting out this you need to change the H1 margin in the style declaration */
- $second_step[42] . /* From date */
- $second_step[43] . /* To date */
- $second_step[44] . /* Company */
- $second_step[45] . /* Employment condition (full-time/part-time) */
- $second_step[46] . /* Department */
- //$second_step[47] .
- //'<hr>'; /* Horizontal rule */
- '</div>';
- ///Convert special chars
- $converted = iconv("UTF-8", "UTF-8//TRANSLIT", $final_output);
- ///Display the final result
- echo $converted;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement