Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- @set_time_limit(0);
- error_reporting(0);
- function brute($spec , $pageno){
- //http://health.hamariweb.com/spcialityDocs.aspx?sid=4&cityId=1
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "health.hamariweb.com/spcialityDocs.aspx?sid=".$spec."&cityId=1");
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
- curl_setopt($ch, CURLOPT_USERAGENT, "Chrome/36.0.1985.125");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS,
- "RenderPartial=1&RenderPartial_PageNum=".$pageno);
- $login = curl_exec($ch);
- return $login;
- }
- function getSslPage($url)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_REFERER, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_USERAGENT, "Chrome/36.0.1985.125");
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
- }
- function clean($string) {
- $string = str_replace('"', '', $string);
- return str_replace("'", "", $string); // Removes special chars.
- }
- // 19 urologist
- //4,23,5,3,14,40,59,42,19,
- $arr_spec = array(44,24,87, 75,12);
- foreach ($arr_spec as $spec_) {
- for ($i=1; $i <=16 ; $i++) {
- $spec = brute($spec_,$i);
- preg_match_all ("/\/karachi\/(.*?)'>/", $spec, $matches);
- foreach ($matches[1]as $key) {
- //echo "</br>".$key;
- ob_start();
- $url = 'health.hamariweb.com/'.$key;
- // echo "</br>".$url;
- $doc_data = getSslPage($url);
- preg_match_all ('/<img alt="User Pic" src="(.*?)"/', $doc_data, $matchess);
- //User PIc
- $pic = clean($matchess[1][0]);
- //if($pic != "")
- {
- //if ($pic != "/Images/docDetail.jpg")
- {
- ob_start();
- preg_match_all ("/font-weight: bold;\" href='\/doctors\/(.*?)'>/s", $doc_data, $matcheses);
- $spec = clean($matcheses[1][0]);
- // echo $doc_data;
- //<li class='active'>
- preg_match_all ("/<li class='active'>(.*?)<\/li>/", $doc_data, $matches);
- //Name
- //print_r($matches[1][0]);
- $name= clean($matches[1][0]);
- //<img alt="User Pic" src="https://connect.marham.pk/assets/doctors/7646/dr-ali-abbas-rokadia-dentist-karachi.jpg"
- preg_match_all ("/style='color: Black; font-weight: normal;'>(.*?)<\/span>/", $doc_data, $matchesss);
- //Phone no# 2
- $address = clean($matchesss[1][1])." , ".clean($matchesss[1][5]);
- $timming = clean($matchesss[1][0]);
- $phone1 = $matchesss[1][2];
- $phone2 = $matchesss[1][3];
- $phone3 = $matchesss[1][7];
- $phone = clean($matchesss[1][2])." ".clean($matchesss[1][3])." ".clean($matchesss[1][7]);
- preg_match_all ('/<td class="pull-right1">(.*?)<\/td>/s', $doc_data, $matchess);
- //User PIc
- $qualif = clean($matchess[1][0]);
- if(!($phone1=="" & $phone2=="" & $phone3=="")){
- $img_url="";
- if (!($name=="" || $address=="" || $timming=="" || $qualif =="" )){
- if(strpos($pic,'docDetail') != true){
- $client_id = '7e809e8cb26effb';
- $url = 'https://api.imgur.com/3/image.json';
- $headers = array("Authorization: Client-ID $client_id");
- $pvars = array('image' => "http://health.hamariweb.com/".$pic);
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL=> $url,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_POST => 1,
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_HTTPHEADER => $headers,
- CURLOPT_POSTFIELDS => $pvars
- ));
- $json_returned = curl_exec($curl);
- curl_close ($curl);
- $pms = json_decode($json_returned,true);
- $img_url=$pms['data']['link'];
- if ($img_url == "" || $img_url == null) {
- if (strpos($pic,'hamariweb') !== false) {
- $img_url =$pic;
- }
- else{
- $img_url = "http://health.hamariweb.com/".$pic;
- }
- }
- }
- $sqls ="
- 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');
- ";
- echo $sqls."</br>";
- $myfile = fopen("Doctor_19_1_sql.txt", "a+") or die("Unable to open file!");
- fwrite($myfile, $sqls."\n");
- fclose($myfile);
- }
- }
- ob_end_flush();
- ob_flush();
- flush();
- }
- }
- ob_end_flush();
- ob_flush();
- flush();
- } //
- ob_end_flush();
- ob_flush();
- flush();
- }
- } // end of sepc
- ?>
Add Comment
Please, Sign In to add comment