python perl curl 模拟get请求
2017-10-18 09:13
295 查看
curl: curl http://192.168.137.1:8000/api2/ping/ node2:/root#curl http://192.168.137.1:8000/api2/ping/ "pong"node2:/root# perl 版本: use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; $ua->agent("Mozilla/8.0"); my $host = "http://192.168.137.1:8000/api2/ping/"; my $response = $ua->get($host); $ua->default_headers; if ($response->is_success) { print $response->decoded_content; # or whatever } else { die $response->status_line; } python 版本: # !/usr/bin/env python # -*- coding: utf-8 -*- import urllib2 import urllib import cookielib import json import httplib url = 'http://192.168.137.1:8000/api2/ping/' conn = httplib.HTTPConnection('192.168.137.1', 8000) header={} conn.request('GET', url, '', header) response = conn.getresponse() res = response.read() print res C:\Python27\python.exe C:/Users/TLCB/PycharmProjects/untitled/mycompany/Django/a1.py "pong" import json import urllib import urllib2 url = "https://www.zjcap.cn/web/noauth?productSn=1079&method=%2Fproduct%2Fdetail&platform=web&_=1509514340879" req = urllib2.Request(url) print req print type(req) res_data = urllib2.urlopen(req) res = res_data.read() print res print type(res)
相关文章推荐
- curl perl python 模拟post请求
- curl perl python get 发送json数据
- 在线编程语言模拟(Java,C,Python,R语言,Ruby,PHP,Perl,Go等)
- curl perl python get请求带请求头
- perl和curl 模拟post 发送json数据
- perl 模拟curl post请求
- curl perl Python post 发送自定义请求头
- perl 模拟curl 自定义请求头
- Python+Ghost抓取动态网页图片,并模拟页面Get请求
- perl 模拟curl put请求
- 在线编程语言模拟(Java,C,Python,R语言,Ruby,PHP,Perl,Go等)
- c语言模拟perl python中的数组负数索引
- curl perl python post发送json数据
- curl模拟post提交
- 如何用PYTHON的CGIHTTPSERVER模块模拟POST请求?
- php 使用curl模拟登录人人(校内)网
- selenium与python自动化测试模拟登录百度
- curl模拟登陆总结
- python使用zeroMQ库的套接字模拟服务器客户端通信
- Python爬虫——5-2.使用selenium和phantomjs模拟QQ空间登录