public string getReply() { string strStart = "reply/"; string strEnd = "reply"; int Start, End; if (this.htmlContents.Contains(strStart) && this.htmlContents.Contains(strEnd)) { Start = this.htmlContents.IndexOf(strStart, 0) + strStart.Length; End = this.htmlContents.IndexOf(strEnd, Start); try { string replyCode = this.htmlContents.Substring(Start, End - Start - 2); string replyUrl = "http://vancouver.en.craigslist.ca/reply/" + replyCode; string replyContents = CraigslistHelper.getContents(replyUrl); if (replyContents != "") { string email = CraigslistHelper.getSection(replyContents, "mailto:", "craigslist.org") + "craigslist.org"; return(email.Replace("%40", "@")); } } catch (Exception e) { return(""); } } else { return(""); } return(""); }
private static void getJobs(string[] yourSkills, int yourExperience, string[] mustHaveWords, string[] cantHaveWords) { string[] developerKeywords = new string[] { "developer", "programmer" }; int skillsLength = yourSkills.Length; string[] urls = new string[] { "http://vancouver.en.craigslist.ca/sof/", "http://vancouver.en.craigslist.ca/web/", }; foreach (string url in urls) { using (XmlReader reader = XmlReader.Create(url + "index.rss")) { reader.MoveToContent(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { XElement el = XNode.ReadFrom(reader) as XElement; if (el != null) { Job job = new Job(skillsLength, el.Value); //looking for developer or programmer jobs foreach (string developerKeyword in developerKeywords) { if (job.jobSummary.ToUpper().Contains(developerKeyword.ToUpper())) { job.isApplicableJob = true; } } foreach (string mustHaveWord in mustHaveWords) { if (job.jobSummary.ToUpper().Contains(mustHaveWord.ToUpper())) { job.isApplicableJob = true; } } foreach (string cantHaveWord in cantHaveWords) { if (job.jobSummary.ToUpper().Contains(cantHaveWord.ToUpper())) { job.isApplicableJob = false; } } if (job.isApplicableJob) { //must be within 3 years of experience; for (int j = yourExperience + 3; j < 15; j++) { if (job.jobSummary.ToUpper().Contains(j + " YEARS") || job.jobSummary.ToUpper().Contains(j + "+ YEARS")) { job.notEnoughExperience = true; } } if (!job.notEnoughExperience) { job.htmlContents = CraigslistHelper.getContents(job.url); job.hasSkill = false; int i = 0; //Check if this job is requesting a skill you have foreach (string skill in yourSkills) { if (job.htmlContents.ToUpper().Contains(skill.ToUpper())) { job.jobSkills[i] = skill; i++; job.hasSkill = true; } } if (job.hasSkill) { Console.WriteLine(job.jobTitle); Console.WriteLine("Apply? Y/N"); string response = Console.ReadLine(); //ask if you want to apply to this job if (response.ToUpper() == "Y") { CoverLetterHelper coverLetter = new CoverLetterHelper(job); Document doc = coverLetter.Write(); Email email = new Email(job.replyEmail, "RE: " + job.jobTitle); email.Send(); Console.WriteLine(); } else { Console.WriteLine(); } } } } } } } } } }