All Projects → integrii → Headlesschrome

integrii / Headlesschrome

Licence: mit
A Go package for working with headless Chrome. Run interactive JavaScript commands on web pages with Go and Chrome.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Headlesschrome

Ferret
Declarative web scraping
Stars: ✭ 4,837 (+4218.75%)
Mutual labels:  cli, scraper, chrome
Instascrape
🚀 A fast and lightweight utility and Python library for downloading posts, stories, and highlights from Instagram.
Stars: ✭ 76 (-32.14%)
Mutual labels:  cli, scraper
Mocha Chrome
☕️ Run Mocha tests using headless Google Chrome
Stars: ✭ 66 (-41.07%)
Mutual labels:  chrome, headless
Spam Bot 3000
Social media research and promotion, semi-autonomous CLI bot
Stars: ✭ 79 (-29.46%)
Mutual labels:  cli, scraper
Ferrum
Headless Chrome Ruby API
Stars: ✭ 1,009 (+800.89%)
Mutual labels:  chrome, headless
Gosearch
🔍 Search the Go packages via command-line
Stars: ✭ 48 (-57.14%)
Mutual labels:  cli, package
Puppeteer Walker
a puppeteer walker 🕷 🕸
Stars: ✭ 78 (-30.36%)
Mutual labels:  chrome, headless
Typac
install npm packages along with corresponding typings
Stars: ✭ 29 (-74.11%)
Mutual labels:  cli, package
Sillynium
Automate the creation of Python Selenium Scripts by drawing coloured boxes on webpage elements
Stars: ✭ 100 (-10.71%)
Mutual labels:  scraper, chrome
Npm Try
🚆 Quickly try npm packages without writing boilerplate code.
Stars: ✭ 103 (-8.04%)
Mutual labels:  cli, package
Rod
A Devtools driver for web automation and scraping
Stars: ✭ 1,392 (+1142.86%)
Mutual labels:  scraper, headless
Gowitness
🔍 gowitness - a golang, web screenshot utility using Chrome Headless
Stars: ✭ 996 (+789.29%)
Mutual labels:  chrome, headless
Gub
CLI tool for create an npm package from any repos. 🐳
Stars: ✭ 31 (-72.32%)
Mutual labels:  cli, package
Pitchfork Npm
An Unofficial Pitchfork Music API client for Node.js
Stars: ✭ 50 (-55.36%)
Mutual labels:  cli, scraper
Navalia
A bullet-proof, fast, and reliable headless browser API
Stars: ✭ 950 (+748.21%)
Mutual labels:  chrome, headless
Xa
Beautiful & Customizable logger ❤️
Stars: ✭ 78 (-30.36%)
Mutual labels:  cli, package
Cli
Get a programmable email address. Automate what happens when you receive emails. It's like Zapier for devs who hate emails.
Stars: ✭ 105 (-6.25%)
Mutual labels:  cli, headless
Url To Pdf Api
Web page PDF/PNG rendering done right. Self-hosted service for rendering receipts, invoices, or any content.
Stars: ✭ 6,544 (+5742.86%)
Mutual labels:  chrome, headless
Regina
Fetch new releases from http://www.juno.co.uk/.
Stars: ✭ 6 (-94.64%)
Mutual labels:  cli, scraper
Go Chrome
A golang library for interacting with the Chrome DevTools Protocol. https://chromedevtools.github.io/devtools-protocol/
Stars: ✭ 96 (-14.29%)
Mutual labels:  chrome, headless

DO NOT USE! This project does not work anymore due to changes in Chrome. Use the Chrome DevTools protocol in chromedp instead!

headlessChrome 🤖

Support only for Ubuntu on Docker for now. Mac appears to not be working. 😬

A go package for working with headless Chrome. Run interactive JavaScript commands on pages with go and Chrome without a GUI. Includes a few helpful functions out of the box to query and click selector paths by their classes, divs, or html content.

You could use this package to click buttons and scrape content on/from a website as if you were a browser, or to render pages that wouldn't be supported by other things like phantomjs or casperjs. Especially useful for sites that use EmberJS, where the content is rendered by javascript after the HTML payload is delivered.

Examples

An example project that does some simple things with a Makefile and Dockerfile is in the examples directory.

Install

go get github.com/integrii/headlessChrome

Documentation

http://godoc.org/github.com/integrii/headlessChrome

Docker Version

To run Chrome headless with docker, check out examples/docker/main.go as well as examples/docker/Makefile. When in that directory, you can do make test to build and run the container with the example app inside. You will see the source of httpbin.org displayed at the end of the build and run.

Custom Flags

By default, we startup with the bare minimum flags necessary to start headless chrome and open a javascript console. If you want more flags, like a resolution size, or a custom User-Agent, you can specify it by replacing the Args variable. Just be sure to append to it so you don't kill the default flags...

headlessChrome.Args = append(headlessChrome.Args,"--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36")
headlessChrome.Args = append(headlessChrome.Args,"--window-size=1024,768")
Changing the Path to Chrome

Change the path to Chrome by simply setting the headlessChrome.ChromePath variable.

headlessChrome.ChromePath = `/opt/google/chrome-unstable/chrome`
JavaScript Helper Examples

Find the full list in the docs.

// click some span element from the page by its text content
browser.ClickItemWithInnerHTML("span", "Google Search",0)

// select the content of something by its css classes
browser.GetContentOfItemWithClasses("button arrow bold",0)
time.Sleep(time.Second) // give it a second to query

// read the selected stuff from the console by picking
// the next item from the output channel
fmt.Println(<-browser.Output)

Contributing

Please send pull requests! It would be good to have support for more operating systems or more handy helpers to run more commonly used javascript code easily. Adding support for other operating systems should be as simple as checking the platform type and changing the ChromePath variable's default value.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].