Page 1 of 1

craigslist job auto-submit

Posted: Thu Oct 06, 2011 7:03 pm
by egg82
Well, I ended up getting pretty bored today, so I decided to look for a job. Foregoing the manual approach, I pulled this together. Some of it is my work, some of it is not.

1. Create a database called "resume"
2. Create a table called "jobs" with "id"(int auto_increment), "link"(varchar), "title"(varchar again), and "email"(varchar once more)
3. Create "resume.doc" in the same folder
4. Edit code below to fit

resume.php

Code: Select all

<?php
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
mysql_connect("", "", "");
mysql_select_db("resume");
$result = mysql_query("TRUNCATE TABLE `jobs`;");
if(!$result){
	echo("Cannot truncate<br>");
	exit();
}

if(!isset($min) or $min == ""){
	$min = 0;
}
if(!isset($max) or $max == ""){
	$max = 10;
}
if(!isset($inc) or $inc == ""){
	$inc = $max;
}

echo("Fetching links...<br>");
echo($min."-".$max);
$min2=0;
$max2=$min;
if($max<100){
	$url = "http://fortcollins.craigslist.org/jjj/index0.html";
	$input = file_get_contents($url);
	if(!$input){
		echo("Could not get URL: ".$url."<br>");
	}
	if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)){
		foreach($matches as $match) {
			$pos = strrpos($match[2], ".html");
			if($pos !== false){
				$min2++;
				if($min2>$min){
					$match[3] = mysql_real_escape_string($match[3]);
					$result = mysql_query("INSERT INTO `jobs`(link, title) VALUES(
											'".$match[2]."',
											'".$match[3]."');");
					if(!$result){
						echo("Cannot get job link ".$match[2]." with title ".$match[3]."<br>");
					}
					$max2++;
					if($max2 == $max){
						echo('<form action="resume2.php" method="post" id="redir">');
						echo('<input type="hidden" name="min" value="'.$min.'">');
						echo('<input type="hidden" name="max" value="'.$max.'">');
						echo('<input type="hidden" name="inc" value="'.$inc.'">');
						?>
						</form>
						<script language="JavaScript" type="text/javascript">
						<!--
						document.getElementById('redir').submit();
						//-->
						</script>
						<?
						exit();
					}
				}
			}
		}
	}
}else{
	for($i=$min;$i<$max;$i+=100){
		$url = "http://fortcollins.craigslist.org/jjj/index".$i.".html";
		$input = file_get_contents($url);
		if(!$input){
			echo("Could not get URL: ".$url."<br>");
		}
		if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)){
			foreach($matches as $match) {
				$pos = strrpos($match[2], ".html");
				if($pos !== false){
					$min2++;
					if($min2>$min){
						$match[3] = mysql_real_escape_string($match[3]);
						$result = mysql_query("INSERT INTO `jobs`(link, title) VALUES(
												'".$match[2]."',
												'".$match[3]."');");
						if(!$result){
							echo("Cannot get job link ".$match[2]." with title ".$match[3]."<br>");
						}
						$max2++;
						if($max2 == $max){
							echo('<form action="resume2.php" method="post" id="redir">');
							echo('<input type="hidden" name="min" value="'.$min.'">');
							echo('<input type="hidden" name="max" value="'.$max.'">');
							echo('<input type="hidden" name="inc" value="'.$inc.'">');
							?>
							</form>
							<script language="JavaScript" type="text/javascript">
							<!--
							document.getElementById('redir').submit();
							//-->
							</script>
							<?
							exit();
						}
					}
				}
			}
		}
	}
}
echo('<form action="resume2.php" method="post" id="redir">');
echo('<input type="hidden" name="min" value="'.$min.'">');
echo('<input type="hidden" name="max" value="'.$max.'">');
echo('<input type="hidden" name="inc" value="'.$inc.'">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
resume2.php

Code: Select all

<?php
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
mysql_connect("", "", "");
mysql_select_db("resume");

$result = mysql_query("SELECT * FROM `jobs`");
if(!$result){
	echo("Cannot get data<br>");
	exit();
}

if(!isset($min) or $min == ""){
	echo('<form action="resume.php" method="post" id="redir">');
	?>
	</form>
	<script language="JavaScript" type="text/javascript">
	<!--
	document.getElementById('redir').submit();
	//-->
	</script>
	<?
}
if(!isset($max) or $max == ""){
	echo('<form action="resume.php" method="post" id="redir">');
	?>
	</form>
	<script language="JavaScript" type="text/javascript">
	<!--
	document.getElementById('redir').submit();
	//-->
	</script>
	<?
}
if(!isset($inc) or $inc == ""){
	echo('<form action="resume.php" method="post" id="redir">');
	?>
	</form>
	<script language="JavaScript" type="text/javascript">
	<!--
	document.getElementById('redir').submit();
	//-->
	</script>
	<?
}

echo("Getting e-mails...<br>");
while($row = mysql_fetch_array($result)){
	$url = $row["link"];
	$input = file_get_contents($url);
	if(!$input){
		echo("Could not get URL: ".$url."<br>");
	}
	if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)){
		foreach($matches as $match) {
			if(preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $match[3])){
				$match[3] = mysql_real_escape_string($match[3]);
				$result2 = mysql_query("UPDATE `jobs` SET `email`='".$match[3]."' WHERE `id`=".$row["id"].";");
				if(!$result2){
					echo("Cannot submit ".$match[3]."<br>");
				}
			}
		}
	}
}
echo('<form action="resume3.php" method="post" id="redir">');
echo('<input type="hidden" name="min" value="'.$min.'">');
echo('<input type="hidden" name="max" value="'.$max.'">');
echo('<input type="hidden" name="inc" value="'.$inc.'">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
resume3.php

Code: Select all

<?php
$attachment = chunk_split(base64_encode(file_get_contents("resume.doc")));
mysql_connect("", "", "");
mysql_select_db("resume");

$result = mysql_query("SELECT * FROM `jobs`");
if(!$result){
	echo("Cannot get e-mails<br>");
	exit();
}

if(!isset($min) or $min == ""){
	echo('<form action="resume.php" method="post" id="redir">');
	?>
	</form>
	<script language="JavaScript" type="text/javascript">
	<!--
	document.getElementById('redir').submit();
	//-->
	</script>
	<?
}
if(!isset($max) or $max == ""){
	echo('<form action="resume.php" method="post" id="redir">');
	?>
	</form>
	<script language="JavaScript" type="text/javascript">
	<!--
	document.getElementById('redir').submit();
	//-->
	</script>
	<?
}
if(!isset($inc) or $inc == ""){
	echo('<form action="resume.php" method="post" id="redir">');
	?>
	</form>
	<script language="JavaScript" type="text/javascript">
	<!--
	document.getElementById('redir').submit();
	//-->
	</script>
	<?
}

echo("Sending e-mails...<br>");
while($row = mysql_fetch_array($result)){
	if(isset($row["email"]) and $row["email"] != ""){
		 $to = $row["email"];
		 $subject = "Replying to ".$row["title"];
		 $random_hash = md5(date('r', time()));
		 $headers = "From: you@yoursite.com\r\nReply-To: you@yoursite.com";
		 $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
		 $output = "
		 --PHP-mixed-$random_hash;
		 Content-Type: multipart/alternative; boundary='PHP-alt-$random_hash'
		 
		 --PHP-alt-$random_hash
		 Content-Type: text/html; charset='iso-8859-1'
		 Content-Transfer-Encoding: 7bit
		 
		 --PHP-alt-$random_hash--
		 
		 --PHP-mixed-$random_hash
		 Content-Type: application/msword; name=resume.doc
		 Content-Transfer-Encoding: base64
		 Content-Disposition: attachment
		 
		 $attachment
		 --PHP-mixed-$random_hash--";
		 
		 if(!mail($to, $subject, $output, $headers)){
				 echo("Mail could not be sent to ".$to);
		 }
	}
}

echo("Done. Waiting 20 seconds for flood interval...<br>");
sleep(20);

$min += $inc;
$max += $inc;
echo('<form action="resume.php" method="post" id="redir">');
echo('<input type="hidden" name="min" value="'.$min.'">');
echo('<input type="hidden" name="max" value="'.$max.'">');
echo('<input type="hidden" name="inc" value="'.$inc.'">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>

Re: craigslist job auto-submit

Posted: Fri Oct 07, 2011 10:17 am
by egg82
Edited:

1. No longer floods your mail server
2. More accurate
3. Amount of jobs customizable
4. Automatically goes through the steps. Set it and forget it

Re: craigslist job auto-submit

Posted: Fri Feb 17, 2012 10:23 am
by egg82
wow, talk about an old post!

Craigslist has an anti-spam system in place. Use this method without an authorized SMTP and it goes right to the trash
Than again, some of the spam you get in return is quite entertaining

Edit: Also doesn't work with new PHP versions. It uses global variables, which are depricated

'Nother edit: Now it looks like i'm talking to myself :(