Skip to content

Instantly share code, notes, and snippets.

@abhinaykumar
Created August 25, 2023 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhinaykumar/32f2fe6261a9dc61cd1a3ee706a1935d to your computer and use it in GitHub Desktop.
Save abhinaykumar/32f2fe6261a9dc61cd1a3ee706a1935d to your computer and use it in GitHub Desktop.
Scrape page with Nokigiri
# 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