Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'open-uri'
- require 'nokogiri'
- def is_phone(num)
- return false if num.length < 1
- bool_num = /(?:\s+|)((0|(?:(\+|)91))(?:\s|-)*(?:(?:\d(?:\s|-)*\d{9})|(?:\d{2}(?:\s|-)*\d{8})|(?:\d{3}(?:\s|-)*\d{7}))|\d{10})(?:\s+|)/.match(num)
- if bool_num != nil
- return true
- else
- return false
- end
- end
- def is_email?(str)
- # To check if a given string is an email address
- return false if str.length < 1
- bool = /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/.match(str)
- if bool != nil
- return true
- else
- return false
- end
- end
- parsed_page = Nokogiri::HTML(open("http://www.airindia.in/contact-details.htm")).text
- parsed_page = parsed_page.split(' ')
- #################### To store all numbers emails ######################
- all_emails = []
- all_numbers = []
- ############################################################
- parsed_page.each do |pa|
- if is_email?(pa)
- all_emails << pa
- elsif is_phone(pa)
- all_numbers << pa
- end
- end
- puts all_emails
- puts all_numbers
- ''' Returned Result
- call.del@airindia.in
- call.bom@airindia.in
- traveldocs@airindia.in
- eCommerce@airindia.in
- flying-returns.ai@iclployalty.com
- airindiaretros.ai@iclployalty.com
- starallianceretros.ai@iclployalty.com
- silveredge.ai@iclployalty.com
- goldenedge.ai@iclployalty.com
- maharajahclub.ai@iclployalty.com
- +91-22-25818515
- +91-44-66921455.
- 011-24624074
- 011-24624075
- '''
Add Comment
Please, Sign In to add comment