Skip to content

Commit

Permalink
Merge branch 'challenge'
Browse files Browse the repository at this point in the history
  • Loading branch information
Krugloff committed Jul 9, 2024
2 parents da474e6 + f33291c commit 34e86d3
Show file tree
Hide file tree
Showing 69 changed files with 104,581 additions and 17 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI
on:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
# opened, synchronize, reopened by default
pull_request:
push:
branches:
- master # only on push to master branch
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
steps:
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v4 # download the repository
# https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
- uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version # read from file
bundler-cache: true # automatically run bundle install and cache the result

- name: Run Tests
env:
RAILS_ENV: test
run: bundle exec rspec ./specs
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-3.2.4
28 changes: 28 additions & 0 deletions CHALLENGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Extract Van Gogh Paintings Code Challenge

Goal is to extract a list of Van Gogh paintings from the attached Google search results page.

![Van Gogh paintings](https://github.com/serpapi/code-challenge/blob/master/files/van-gogh-paintings.png?raw=true "Van Gogh paintings")

## Instructions

This is already fully supported on SerpApi. ([relevant test], [html file], [sample json], and [expected array].)
Try to come up with your own solution and your own test.
Extract the painting `name`, `extensions` array (date), and Google `link` in an array.

Fork this repository and make a PR when ready.

Programming language wise, Ruby (with RSpec tests) is strongly suggested but feel free to use whatever you feel like.

Parse directly the HTML result page ([html file]) in this repository. No extra HTTP requests should be needed for anything.

[relevant test]: https://github.com/serpapi/test-knowledge-graph-desktop/blob/master/spec/knowledge_graph_claude_monet_paintings_spec.rb
[sample json]: https://raw.githubusercontent.com/serpapi/code-challenge/master/files/van-gogh-paintings.json
[html file]: https://raw.githubusercontent.com/serpapi/code-challenge/master/files/van-gogh-paintings.html
[expected array]: https://raw.githubusercontent.com/serpapi/code-challenge/master/files/expected-array.json

Add also to your array the painting thumbnails present in the result page file (not the ones where extra requests are needed).

Test against 2 other similar result pages to make sure it works against different layouts. (Pages that contain the same kind of carrousel. Don't necessarily have to be paintings.)

The suggested time for this challenge is 4 hours. But, you can take your time and work more on it if you want.
19 changes: 19 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
source "https://rubygems.org"

ruby "3.2.4"

# for parsing html documents to nodes tree
# see nokogiri_based_knowledge_graph.rb
gem 'nokogiri'
gem 'nokolexbor'

group :development do
# https://github.com/SamSaffron/memory_profiler
# see benchmarks/memory.rb
gem 'memory_profiler'
gem 'debug'
end

group :test do
gem 'rspec'
end
70 changes: 70 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
GEM
remote: https://rubygems.org/
specs:
debug (1.9.2)
irb (~> 1.10)
reline (>= 0.3.8)
diff-lcs (1.5.1)
io-console (0.7.2)
irb (1.13.2)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
memory_profiler (1.0.2)
nokogiri (1.16.6-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.6-arm-linux)
racc (~> 1.4)
nokogiri (1.16.6-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86-linux)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-linux)
racc (~> 1.4)
nokolexbor (0.5.4)
nokolexbor (0.5.4-arm64-darwin)
nokolexbor (0.5.4-x86_64-darwin)
nokolexbor (0.5.4-x86_64-linux)
psych (5.1.2)
stringio
racc (1.8.0)
rdoc (6.7.0)
psych (>= 4.0.0)
reline (0.5.9)
io-console (~> 0.5)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
stringio (3.1.1)

PLATFORMS
aarch64-linux
arm-linux
arm64-darwin
x86-linux
x86_64-darwin
x86_64-linux

DEPENDENCIES
debug
memory_profiler
nokogiri
nokolexbor
rspec

RUBY VERSION
ruby 3.2.4p170

BUNDLED WITH
2.5.10
Loading

0 comments on commit 34e86d3

Please sign in to comment.