Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Brotli #751

Open
todd-bush opened this issue Feb 8, 2023 · 2 comments
Open

Support for Brotli #751

todd-bush opened this issue Feb 8, 2023 · 2 comments

Comments

@todd-bush
Copy link

I've run into a few sites that are compressing using Brotli over gzip.

https://chromestatus.com/feature/5420797577396224

Native support for Brotli would be a nice enhancement.

Also, if there's a workaround to handle Brotli sites, please let me know.

@vvo459
Copy link

vvo459 commented Jan 29, 2024

For me, this workaround helped:

import
"github.com/andybalholm/brotli"

c.OnResponse(func(r *colly.Response) {
....

  if contentEncodingHeader == "br" {
        bodyReader := bytes.NewReader(r.Body)
        brReader := brotli.NewReader(bodyReader)
        decompressed, err := io.ReadAll(brReader)
        if err != nil {
            log.Println("Error during Brotli decompression:", err)
        }
        decompressedBody = string(decompressed)
  } 

}

@truthtracer
Copy link

I've add br support on https://github.com/truthtracer/colly, you can try it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants