go 获取网址html 源码
2024-10-18 05:50:08
// Sample program to show how to write a simple version of curl using
// the io.Reader and io.Writer interface support.
package main import (
"fmt"
"io"
"net/http"
"os"
) // init is called before main.
func init() {
if len(os.Args) != {
fmt.Println("Usage: ./example2 <url>")
os.Exit(-)
}
} // main is the entry point for the application.
func main() {
// Get a response from the web server.
r, err := http.Get(os.Args[])
if err != nil {
fmt.Println(err)
return
} // Copies from the Body to Stdout.
io.Copy(os.Stdout, r.Body)
if err := r.Body.Close(); err != nil {
fmt.Println(err)
}
}
执行
go run test.go http://www.baidu.com
最新文章
- 谈谈我的微软特约稿:《SQL Server 2014 新特性:IO资源调控》
- 2016总结&;2017计划
- 第4月第2天 nsinvocation崩溃 mvc videotrack
- (Hibernate进阶)Hibernate基本映射(三)
- JMir——Java版热血传奇2之资源文件与地图
- 【Spring 1】Spring简介
- NOI 2014 感想
- 激活Navicat?如何注册Navicat?
- 【python】使用unix管道pipe处理stdout实时数据
- [Postman]拦截器扩展(15)
- 网络编程—网络基础概览、socket,TCP/UDP协议
- 《Java并发编程的艺术》--Java中的锁
- 利用yum搭建lamp环境并进一步创建博客
- Vue.js 2.0生命周期
- include 模板标签
- Notepad++语言格式设置,自定义扩展名关联文件格式
- 【three.js练习程序】旋转、缩放场景
- java UTC时间和local时间相互转换
- [Android&;amp;Java]浅谈设计模式-代码篇:观察者模式Observer
- Windows上编译LLVM 3.2
热门文章
- Different between MB SD Connect Compact 5 and MB SD C4 Star Diagnostic Tool
- glog日志库移植Android平台
- golang fatal error: all goroutines are asleep - deadlock!
- HAProxy实现slave负载均衡[高可用]
- 模拟实现ATM+购物商城程序
- GDPR
- ODAC(V9.5.15) 学习笔记(九)TOraSQLMonitor
- Python3 tkinter基础 Canvas coords 移动直线,itemconfig 设置矩形的颜色, delete 删除一条直线
- 修改userdata的分区大小【转】
- 一些常用的mysql语句实例-以后照写