爬虫---请求

news/2024/7/19 9:17:46 标签: 爬虫, json, python

http请求,或者response都是二进制的

 

1.urllib不推荐用

1.1 python内置的HTTP请求库

urllib.request   请求

urllib.error     异常

urllib.parse    url拼接

urllib.robotparse     不用

1.2urllib.request

http://httpbin.org/:这是一个http测试网站,比如测ip,测你的http请求

加header

加form表单

url中加如参数

cookie的读取

代理的设置

对象:request,response,opener,handler

 

2.requests

发送带参的get请求

发送post请求

设置代理

会加headers

会话维持,(如何取出cookie查看)

忽略证书

返回的二进制,字符串

json变dict

文件上传files

超时设置

 

转载于:https://www.cnblogs.com/BlueFire-py/p/8763567.html


http://www.niftyadmin.cn/n/977137.html

相关文章

[Poj1273]Drainage Ditches(网络流)

Description 给图&#xff0c;求最大流 最大流模板题&#xff0c;这里用dinic Code #include <cstdio> #include <cstring> #include <algorithm> #define Inf 0x7fffffff #define N 210 using namespace std;int g[N][N],d[N],q[N*10],h,t; int n,m,Ans,tmp…

vagrant折腾记,ssh无法登陆?虚拟机添加独立ip无法ping通?

为什么80%的码农都做不了架构师&#xff1f;>>> 环境概述 vagrant1.8.4virtualbox 4.3宿主机系统&#xff1a;centos7.2虚拟机box: centos/7初始化 vagrant box add centos/7 mkdir vm1 cd vm1 vagrant init centos/7启动 vagrant upok成功报错&#xff1a;"W…

实例 find

2011/09/08 12:00 时间开始找一天內的&#xff0c;会列出 2011/09/07 12:00 ~ 2011/09/08 12:00 时间內的文件3天前被改动过的文件 (前第三天以前 → 2011/09/05 12:00 以前的文件) (> 72 小时)find /var/log/ -mtime 3 -type f -print 3天內被改动过的文件 (2011/09/05 12:…

httpclient调用https

httpclient调用https报错&#xff1a; Exception in thread "main" java.lang.Exception: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed 代码&#xff1a; pac…

【转】 JUnit单元测试--IntelliJ IDEA

原文地址&#xff1a;https://blog.csdn.net/weixin_38104426/article/details/74388375 使用idea IDE 进行单元测试&#xff0c;首先需要安装JUnit 插件。 1.安装JUnit插件步骤 File-->settings-->Plguins-->Browse repositories-->输入JUnit-->选择JUnit Gene…

nodejs v8.9.4 安装

一.安装环境Centos7.3 64位 wget https://nodejs.org/dist/v8.9.4/node-v8.9.4.tar.gz cd node-v8.9.4/ ./configure --prefix/usr/local/nodejsmakemake install 二.nodejs设置环境变量vim /etc/profile.d/nodejs.sh#输入以下内容export NODEJS_HOME/usr/local/nodejsPATH$PAT…

mongodb,redis,hbase 三者都是nosql数据库,他们的最大区别和不同定位是什么?

不严谨地讲&#xff0c;Redis定位在"快"&#xff0c;HBase定位于"大",mongodb定位在"灵活"。 NoSQL的优点正好就是SQL的软肋&#xff0c;而其弱点正好也就是SQL的杀手锏-----------------------------------------最大区别在于&#xff0c;在一般…