Skip to content

Instantly share code, notes, and snippets.

@ariankordi ariankordi/adsense.go
Last active Sep 10, 2018

Embed
What would you like to do?
A little Go script that gets the AdSense revenue you have this month
package main
import (
"github.com/valyala/fasthttp"
"bytes"
"fmt"
)
var req = fasthttp.AcquireRequest()
var resp = fasthttp.AcquireResponse()
var client = &fasthttp.Client{}
//const cookie = "Paste the cookie you see when going to AdSense here, you have to uncomment this const"
func main() {
req.Header.SetMethod("POST")
req.Header.Add("Client-Version", "44084f1953159cf725c5620637189f1689d48d6f")
req.Header.Add("X-Lightfe-Auth", "1")
req.Header.Add("Cookie", cookie)
req.SetRequestURI("https://www.google.com/adsense/m/data/home")
client.Do(req, resp)
thisMonthPart1 := bytes.Split(resp.Body(), []byte("month "))[1]
thisMonthPart2 := bytes.Split(thisMonthPart1, []byte("$"))[1]
thisMonthPart3 := bytes.Split(thisMonthPart2, []byte("\""))[0]
fmt.Println(string(thisMonthPart3))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.