How to analyze Google search results using Nokogiri?

I need help pulling URLs from google search results and I was told to use Nokogiri. I installed it and read the Nokogiri documents, but I have no idea where to start - it's all Greek to me.

I know that I am looking for the URL of each result, each of which exists between the <cite> . For now, all I could figure out how to do was print the search results, but I just don’t know how to get certain data from the file. Here is a tiny bit of code that I have:

 serp = Nokogiri::HTML(open("http://www.google.com/search?num=100&q=stackoverflow")) 
+6
source share
1 answer

enjoy :)

 require 'open-uri' require 'nokogiri' page = open "http://www.google.com/search?num=100&q=stackoverflow" html = Nokogiri::HTML page html.search("cite").each do |cite| puts cite.inner_text end 

also look nokogiri tutorials

+10
source

Source: https://habr.com/ru/post/888208/


All Articles