Created
August 25, 2023 07:34
-
-
Save abhinaykumar/32f2fe6261a9dc61cd1a3ee706a1935d to your computer and use it in GitHub Desktop.
Scrape page with Nokigiri
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://soravjain.com/digital-marketing-agencies-india/ | |
data = [] | |
email= nil | |
address=nil | |
phone=nil | |
website=nil | |
services=nil | |
brands=nil | |
doc.css("p").each do |x| | |
if x.content.start_with?("Services") | |
address = x.content | |
elsif x.content.start_with?("Email") | |
email = x.content | |
elsif x.content.start_with?("Phone") | |
phone = x.content | |
elsif x.content.start_with?("Address") | |
services = x.content | |
elsif x.content.start_with?("Brands") | |
brands = x.content | |
elsif x.content.start_with?("Website") | |
website = x.content | |
data << [email, address, phone, website, services, brands] | |
email= nil | |
address=nil | |
phone=nil | |
website=nil | |
services=nil | |
brands=nil | |
end | |
end | |
File.write("ss.csv", data.map(&:to_csv).join) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment