GithubHelp home page GithubHelp logo

Comments (9)

zjlx avatar zjlx commented on July 19, 2024 1

It is so cute.
I just learned golang.
I will recommend this library to more people.

from rod.

ysmood avatar ysmood commented on July 19, 2024

If you check the doc of https://chromedevtools.github.io/devtools-protocol/tot/Network#method-setCookie

There's another method below Network.setCookie called Network.setCookies. you can do something like this:

page.Call("Network.setCookies", cdp.Object{ "cookies": []cdp.Object{{
		"domain":         ".test.com",
		"expirationDate": 158255720, // TODO: fix the field name and value here
		"hostOnly":       true,
		"httpOnly":       true,
		"name":           "datr",
		"path":           "/",
		"sameSite":       "no_restriction", // TODO: fix the field name and value here
		"secure":         false,
		"session":        false,
		"storeId":        "0",
		"value":          "5798798Q2B-",
		"id":             1,
	}, {
		"domain":         ".test.com",
		"expirationDate": 15985720,
		"hostOnly":       true,
		"httpOnly":       true,
		"name":           "bs",
		"path":           "/",
		"sameSite":       "no_restriction",
		"secure":         false,
		"session":        false,
		"storeId":        "0",
		"value":          "8DfXXcNRyf9zIM57nG4Maa1c",
		"id":             2,
	}}})

from rod.

ysmood avatar ysmood commented on July 19, 2024

One more thing you need to be careful. Your data structure seems copied from a python lib which is not compatible with the chrome protocol, you need to modify some fields' name and value to match the format: https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-setCookie

from rod.

ysmood avatar ysmood commented on July 19, 2024

BTW, I added a new method to version v0.26.1 to make it easier:

https://github.com/ysmood/rod/blob/89448d3c6685838bba0421bc1693802c3609831d/page_test.go#L23

from rod.

zjlx avatar zjlx commented on July 19, 2024

Thanks for your relay.
The cookies is export from chrome plugin "Edit This Cookie".
The new method page.SetCookies(cdp.Object{}) it means can only setcookie not setcookies, or it can be pass in []cdb.Object{}?

from rod.

ysmood avatar ysmood commented on July 19, 2024

page.SetCookies can receive array, you'd better learn the golang syntax ....

Check this first: https://gobyexample.com/variadic-functions

from rod.

zjlx avatar zjlx commented on July 19, 2024

So sorry about that ,I will learn more basic knowledge.
By the way, can the name of the library be longer? It's related to chrome or some keyword related libraries. Now, searching for the same name of rod is not conducive to being understood by more people.Just a suggestion.

from rod.

ysmood avatar ysmood commented on July 19, 2024

The name rod is actually related to puppetry:

Screen Shot 2020-04-24 at 14 43 43

I think it's a common issue for new projects. Once it's popular search for go rod will definitely get you here, just some search engine trick. So if you like it, you can help to share it with more people, such as create a tutorial when you are learning to use it, etc.

Here my ongoing tutorial for it, I think it will help a lot of people step into the scraper world after it's finished: https://github.com/ysmood/github-trending

from rod.

ysmood avatar ysmood commented on July 19, 2024

Thank you! I think I can close this ticket for now.

from rod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.