All you need to scrape raw ads.
Provide a file with keywords, get ads from Google search and store them in a database.
Go to golang.org downloads page, download the binary for your architecture and then follow the installation instructions. It's probably as simple as (running with super user privileges)
$ tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
It's recommended to use the default installation location and not set the GOROOT
environment variable.
The package was built with Go version 1.8.x.
Add this to your shell's init scripts.
$ export PATH=$PATH:/usr/local/go/bin
Go to the official PostgreSQL downloads page. Follow the instructions for your operating system. If you're on Linux, PostgreSQL will most likely be already included in your package manager sources. If you're on macOS you can use Homebrew.
Don't forget to install both the server and the client libraries.
$ git clone git@github.com:gkats/adscraper.git
You can set the GOPATH
environment variable to whatever you like, however the project assumes that it's cloned under $(GOPATH)/src/github.com/gkats/
. There is a helper file provided to automatically set the GOPATH
variable.
Go to the root directory and source the .gopath
file.
$ . .gopath
This sets the GOPATH
environment variable to the project root.
Happy hacking!
The package contains a Makefile
for building with GNU Make. There are various targets in the Makefile. The default just builds (compiles) the package.
Before you run any Makefile rules, you need to set your GOPATH
. The GOPATH
variable's value is tightly related to the way you've set up your project directory hierarchy. It is recommended that you follow the $(GOPATH)/src/github.com/gkats/adscraper
directory structure. All you have to do then is source .gopath
from the project root. While you can source the file only once, we'll include the directive for every run of make.
- To install the package run
$ . .gopath && make install
# or
$ GOPATH=/path/to/gopath make install
The above command also runs gofmt
and govet
before installing the package.
- To build the package run
$ . .gopath && make build
# or
$ GOPATH=/path/to/gopath make build
- You can also run
gofmt
andgovet
$ . .gopath && make fmt
# or
$ GOPATH=/path/to/gopath make fmt
$ . .gopath && make vet
# or
$ GOPATH=/path/to/gopath make vet
Not much here at this point. Run with
$ . .gopath && go test
There are three separate programs bundled in the repo.
keywords The main keywords program reads keywords from a file and stores them into the database. Once installed, you can invoke the program with
$ $(GOPATH)/bin/keywords -f absolute/path/to/keywords/file -d user:password\@host:port/database
You need to create a keywords file first. For an example see the sample ./keywords.dat.sample
.
When you're in doubt just run $ $(GOPATH)/bin/keywords --help
.
server This is an HTTP server used to read keywords, store ads and update the keywords scraping data. Run the program with
$ $(GOPATH)/bin/server -d user:password\@host:port/database
Run $ $(GOPATH)/bin/server --help
for more information.
adscraper The application that scrapes raw ads from google results. It performs a request to get least scraped keywords (random), queries google for results and then posts them back to the server. Run it with
$ $(GOPATH)/bin/adscraper -h https://server.hostname
Run $ $(GOPATH)/bin/adscraper --help
for more information.
The license is MIT. Feel free to fork this and use it.
Due to the frequent changes in the Google search results page, some or all code in this package might not work.
Finally, please consult with Google search's terms of use before using this library.