kernelpanek icon

Simple Webpage Fetcher

kernelpanek | PRO | 02/18/23 05:45:42 PM UTC | 0 ⭐ | 15447 👁️ | Never ⏰ | [http, webclient]
Go |

670 B

|

Software

|

0 👍

/

0 👎

package main
 
import (
    "fmt"
    "io"
    "net/http"
)
 
func main() {
    // Create an HTTP client with default settings
    client := &http.Client{}
 
    // Make an HTTPS GET request to example.com
    resp, err := client.Get("https://pastebin.com")
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()
 
    // Print the response body
    fmt.Println(resp.Status)
    fmt.Println(resp.Header)
    // Read the response body and convert it to a string
 
    bodyBytes, err := io.ReadAll(resp.Body)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    bodyString := string(bodyBytes)
 
    // Print the response body as a string
    fmt.Println(bodyString)
}
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎