macropusgiganteus / scrappy-web

Project for Technical Test
0 stars 0 forks source link

Add search result. As a user, I can search for keyword and view search result #4

Closed macropusgiganteus closed 1 month ago

macropusgiganteus commented 1 month ago

What happened πŸ‘€

Insight πŸ“

How searching for each keyword works

For each keyword, I sequentially send a get request to http://www.google.com/search?q=#{keyword}&hl=en (use hl=en to get the result in English) NOTE: this can be improved by sending multiple requests simultaneously.

How extracting data from HTML works

I used nokogiri css selector to extract data from the HTML document.

  1. total_search_results image selector: div#result-stats
  2. total_links I count <a> tag in the page
  3. total_ads selector: div#tads[aria-label=Ads] (if not found, fallback to div#tads) Then return element.childrent.count image

Proof Of Work πŸ“Ή

image

scrappy-web-search-keywords