Showing posts with label scrape yellow pages. Show all posts
Showing posts with label scrape yellow pages. Show all posts

Tuesday, July 17, 2012

Scrape email from yellow pages and send them email with 300 second delay


em = []
(1..63).each do |i|
yp = Nokogiri::HTML(open("http://www.yellowpages.com.my/search.jsp?sfor=all&name=logistic&w=&p=#{i}"))
emails = yp.search("a.email").map{|x| x["onclick"].gsub("SqueezeBox.open('/plainmail.jsp?id=", "").split("',")[0] }
emails.each do |eid|
  t = Nokogiri::HTML(open("http://yellowpages.com.my/plainmail.jsp?id=#{eid}"))
  em.push(t.search("input").first["value"])
end
InvoiceMailer.inquiry(em).deliver
sleep 300
end