requests

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2022 License: GPL-3.0 Imports: 27 Imported by: 0

README

Requests-Light

Go Report Card CodeFactor

轻量级Requests,主要目的为快速实现简单的HTTP请求,避免过多的内容处理。

安装

go get github.com/sari3l/requests-light

使用

package main

import (
    "fmt"
    "github.com/sari3l/requests-light"
    "github.com/sari3l/requests-light/ext"
)

func main() {
    resp := requests.Get("https://www.google.com", ext.Proxy("http://127.0.0.1:7890"))
    fmt.Println(resp.Html)
}

Licenses

MIT License

Documentation

Index

Constants

View Source
const DefaultTimeout = 5 // time.Second
View Source
const Version = "v1.0.0"

Variables

This section is empty.

Functions

func PrepareRequest

func PrepareRequest(method string, url string, params types.Dict, headers types.Dict, cookies types.Dict, data types.Dict, json map[string]any, files types.Dict, stream io.Reader, auth types.AuthInter, hooks types.HooksDict) (error, *prepareRequest)

func Session

func Session(timeout int, proxy string, redirect bool, verify bool) *session

Types

type Request

type Request struct {
	*http.Request
}

type Response

type Response struct {
	*http.Response
	Session *session

	History []*Response
	Html    string
	Ok      bool
	Raw     []byte
	Time    int64
	// contains filtered or unexported fields
}

func Delete

func Delete(url string, ext ...types.Ext) *Response

func Get

func Get(url string, ext ...types.Ext) *Response
func Head(url string, ext ...types.Ext) *Response

func Options

func Options(url string, ext ...types.Ext) *Response

func Post

func Post(url string, ext ...types.Ext) *Response

func Put

func Put(url string, ext ...types.Ext) *Response

func (*Response) ContentType

func (resp *Response) ContentType() string

func (*Response) Json

func (resp *Response) Json() *gjson.Result

func (*Response) Save

func (resp *Response) Save(filename string) error

func (*Response) Text

func (resp *Response) Text() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL