Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- # Required files
- require ("{$_SERVER['DOCUMENT_ROOT']}/config/pipeline-x.php");
- include ("linkedin-functions.php");
- include ("simple-html-dom.php");
- # Define variables
- $fn = urlencode($_REQUEST['fn']);
- $ln = urlencode($_REQUEST['ln']);
- # Connect to database
- $db = new px_dbasei();
- $db->connect("192.168.50.70", "jerry", "0ldn3w5", "pipeline_test");
- # Query records that are less than 30 days old
- $sql = "SELECT * FROM linkedin_parse "
- ."WHERE "
- ."`first_name` = '{$fn}' AND "
- ."`last_name` = '{$ln}' AND "
- ."`date_inserted` < DATE_SUB(NOW(), INTERVAL 30 DAY) ";
- $results = $db->query($sql);
- # If no rows return
- if($results->num_rows == 0):
- # Query records if there are match
- $sql = "SELECT * FROM linkedin_parse "
- ."WHERE "
- ."`first_name` = '{$fn}' AND "
- ."`last_name` = '{$ln}' ";
- $results = $db->query($sql);
- # If there are no results then perform INSERT
- if($results->num_rows == 0):
- echo 'Perform INSERT';
- else:
- echo 'Perform UPDATE';
- # Search linkedin and download page
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://www.linkedin.com/pub/dir/?first={$fn}&last={$ln}&search=Search");
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0");
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
- curl_setopt($ch, CURLOPT_TIMEOUT, 8);
- $res = curl_exec($ch);
- curl_close($ch);
- $html = str_get_html($res);
- parse_records($html);
- print_r($table);
- endif;
- endif;
Advertisement
Add Comment
Please, Sign In to add comment