H4T3D

health

Aug 15th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.87 KB | None | 0 0
  1. <?php
  2.  
  3. @set_time_limit(0);
  4. error_reporting(0);
  5.  
  6. function brute($spec , $pageno){
  7.         //http://health.hamariweb.com/spcialityDocs.aspx?sid=4&cityId=1
  8.         $ch = curl_init();      
  9.         curl_setopt($ch, CURLOPT_URL, "health.hamariweb.com/spcialityDocs.aspx?sid=".$spec."&cityId=1");
  10.         curl_setopt($ch, CURLOPT_HEADER, 0);
  11.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  12.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  13.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  14.         curl_setopt($ch, CURLOPT_USERAGENT, "Chrome/36.0.1985.125");
  15.         curl_setopt($ch, CURLOPT_POST, 1);
  16.         curl_setopt($ch, CURLOPT_POSTFIELDS,
  17.             "RenderPartial=1&RenderPartial_PageNum=".$pageno);
  18.         $login = curl_exec($ch);
  19.  
  20.         return $login;
  21. }
  22.  
  23.  
  24.  
  25. function getSslPage($url)
  26. {
  27.         $ch = curl_init();
  28.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  29.         curl_setopt($ch, CURLOPT_HEADER, 0);
  30.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  31.         curl_setopt($ch, CURLOPT_URL, $url);
  32.         curl_setopt($ch, CURLOPT_REFERER, $url);
  33.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  34.         curl_setopt($ch, CURLOPT_USERAGENT, "Chrome/36.0.1985.125");
  35.         $result = curl_exec($ch);
  36.         curl_close($ch);
  37.  
  38.         return $result;
  39. }
  40.  
  41. function clean($string) {
  42.  
  43.     $string = str_replace('"', '', $string);
  44.  
  45.    return str_replace("'", "", $string); // Removes special chars.
  46. }
  47.  
  48. // 19 urologist
  49. //4,23,5,3,14,40,59,42,19,
  50. $arr_spec = array(44,24,87, 75,12);
  51.  
  52.  
  53.  
  54. foreach ($arr_spec as $spec_) {
  55.  
  56.  
  57. for ($i=1; $i <=16 ; $i++) {
  58.  
  59. $spec = brute($spec_,$i);
  60.  
  61. preg_match_all ("/\/karachi\/(.*?)'>/", $spec, $matches);
  62.  
  63. foreach ($matches[1]as $key) {
  64.     //echo "</br>".$key;
  65. ob_start();
  66.  
  67.     $url = 'health.hamariweb.com/'.$key;
  68.   //  echo "</br>".$url;
  69.  
  70.     $doc_data = getSslPage($url);
  71.  
  72.     preg_match_all ('/<img alt="User Pic" src="(.*?)"/', $doc_data, $matchess);
  73. //User PIc
  74. $pic = clean($matchess[1][0]);
  75.  
  76.  
  77.  
  78. //if($pic != "")
  79. {
  80. //if ($pic != "/Images/docDetail.jpg")
  81. {
  82.  
  83. ob_start();
  84.  
  85.     preg_match_all ("/font-weight: bold;\" href='\/doctors\/(.*?)'>/s", $doc_data, $matcheses);
  86.     $spec = clean($matcheses[1][0]);
  87.  
  88. //  echo $doc_data;
  89. //<li class='active'>
  90. preg_match_all ("/<li class='active'>(.*?)<\/li>/", $doc_data, $matches);
  91.  
  92. //Name
  93. //print_r($matches[1][0]);
  94. $name= clean($matches[1][0]);
  95.  
  96. //<img alt="User Pic" src="https://connect.marham.pk/assets/doctors/7646/dr-ali-abbas-rokadia-dentist-karachi.jpg"
  97.  
  98. preg_match_all ("/style='color: Black; font-weight: normal;'>(.*?)<\/span>/", $doc_data, $matchesss);
  99. //Phone no# 2
  100.  
  101. $address = clean($matchesss[1][1])." , ".clean($matchesss[1][5]);
  102.  
  103. $timming = clean($matchesss[1][0]);
  104.  
  105. $phone1 = $matchesss[1][2];
  106. $phone2 = $matchesss[1][3];
  107. $phone3 = $matchesss[1][7];
  108.  
  109. $phone = clean($matchesss[1][2])."  ".clean($matchesss[1][3])."  ".clean($matchesss[1][7]);
  110.  
  111.  
  112.  
  113. preg_match_all ('/<td class="pull-right1">(.*?)<\/td>/s', $doc_data, $matchess);
  114. //User PIc
  115. $qualif = clean($matchess[1][0]);
  116.  
  117. if(!($phone1=="" & $phone2=="" & $phone3=="")){
  118.  
  119.     $img_url="";
  120.  
  121.     if (!($name=="" || $address==""  || $timming=="" || $qualif =="" )){
  122.  
  123.         if(strpos($pic,'docDetail') != true){
  124.  
  125.         $client_id = '7e809e8cb26effb';
  126.         $url = 'https://api.imgur.com/3/image.json';
  127.         $headers = array("Authorization: Client-ID $client_id");
  128.         $pvars  = array('image' => "http://health.hamariweb.com/".$pic);
  129.         $curl = curl_init();
  130.         curl_setopt_array($curl, array(
  131.         CURLOPT_URL=> $url,
  132.         CURLOPT_TIMEOUT => 30,
  133.         CURLOPT_POST => 1,
  134.         CURLOPT_RETURNTRANSFER => 1,
  135.         CURLOPT_HTTPHEADER => $headers,
  136.         CURLOPT_POSTFIELDS => $pvars
  137.         ));
  138.         $json_returned = curl_exec($curl);
  139.         curl_close ($curl);
  140.         $pms = json_decode($json_returned,true);
  141.         $img_url=$pms['data']['link'];
  142.  
  143.  
  144.         if ($img_url == "" || $img_url == null) {
  145.  
  146.         if (strpos($pic,'hamariweb') !== false) {
  147.                 $img_url =$pic;
  148.         }
  149.         else{
  150.                     $img_url = "http://health.hamariweb.com/".$pic;
  151.         }
  152.  
  153.            
  154.         }
  155.     }
  156.  
  157.        
  158.  
  159.  
  160. $sqls ="
  161. INSERT INTO doctor (doc_id, doc_name, doc_email, doc_address, doc_phone, spec, pic, doc_timming, doc_hi_id, doc_qualification, doc_pass, doc_status) VALUES (NULL, '".$name."', '', '".$address."', '".$phone."', '".$spec."', '".$img_url."', '".$timming."', '', '".$qualif."', 'admin123', '0');
  162. ";
  163.     echo $sqls."</br>";
  164.     $myfile = fopen("Doctor_19_1_sql.txt", "a+") or die("Unable to open file!");
  165.     fwrite($myfile, $sqls."\n");
  166.     fclose($myfile);
  167.     }
  168. }
  169.  
  170.      ob_end_flush();
  171.     ob_flush();
  172.     flush();
  173.  
  174. }
  175.  
  176.  
  177. }
  178.  
  179. ob_end_flush();
  180.     ob_flush();
  181.     flush();
  182.  
  183. } //
  184.  
  185.     ob_end_flush();
  186.     ob_flush();
  187.     flush();
  188. }
  189.  
  190. }   // end of sepc
  191.  
  192.         ?>
Add Comment
Please, Sign In to add comment