Skip to content

Commit

Permalink
Tweak example code
Browse files Browse the repository at this point in the history
  • Loading branch information
fredwu committed Sep 30, 2023
1 parent d69b5f6 commit a6b19fa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/google_search.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Crawler.Example.GoogleSearch do
alias Crawler.Example.GoogleSearch.Scraper
alias Crawler.Example.GoogleSearch.UrlFilter

@url "https://www.google.com/search"
@site_url "https://www.google.com/search?"
@search_term "github web scrapers in Elixir"

def run do
Expand All @@ -39,7 +39,7 @@ defmodule Crawler.Example.GoogleSearch do

{:ok, opts} =
Crawler.crawl(
url(),
search_url(),
workers: 2,
max_depths: 2,
max_pages: 10,
Expand All @@ -59,8 +59,8 @@ defmodule Crawler.Example.GoogleSearch do
end)
end

defp url do
@url <> "?" <> URI.encode_query(%{"q" => @search_term})
defp search_url do
@site_url <> URI.encode_query(%{"q" => @search_term})
end

defp wait(fun), do: wait(5_000, fun)
Expand Down

0 comments on commit a6b19fa

Please sign in to comment.