上一页 1 2 3 4 5 6 ··· 8 下一页
摘要: requests库相比于urllib库更好用!!! 0.各种请求方式 *http://httpbin.org是一个http请求验证网站! 1.GET请求 带参数的get请求(两种方式是等效的) 输出结果如下: * params=data 对于get请求 添加附加的格外的信息,这个信息一般用字典来存储 阅读全文
posted @ 2019-04-09 21:30 那是个好男孩 阅读(2696) 评论(0) 推荐(1) 编辑
摘要: urllib库的总结: 用ProcessOn(安利这个软件,够用了)根据前面的几节内容做了个思维导图。 urllib库一共有四个模块: request:它是最基本的模块,可以用来模拟发送请求 error:异常处理模块,如果出现请求错误,我们可以捕获这些异常,然后进行重试或其它操作以保证程序不会意外终 阅读全文
posted @ 2019-04-09 18:11 那是个好男孩 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 1.异常处理 URLError类来自urllib库的error模块,它继承自OSError类,是error异常模块的基类,由request模块产生的异常都可以通过这个类来处理。 输出结果如下: * 这样来理解:URLError 和 HTTPError ==> URLError其子类是HTTPErro 阅读全文
posted @ 2019-04-09 16:55 那是个好男孩 阅读(490) 评论(0) 推荐(0) 编辑
摘要: 在前面我们总结了urllib库的 urlopen()和Request()方法的使用,在这一小节我们要使用相关的Handler来实现代理、cookies等功能。 写在前面: urlopen()方法不支持代理、cookie等其它的HTTP/GTTPS高级功能,所以要支持这些功能: *如果程序里所有的请求 阅读全文
posted @ 2019-04-09 14:58 那是个好男孩 阅读(402) 评论(0) 推荐(0) 编辑
摘要: # 注意一下 是import urllib.request 还是 form urllib import request 0. urlopen() 语法:urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=N 阅读全文
posted @ 2019-04-09 11:29 那是个好男孩 阅读(3895) 评论(0) 推荐(2) 编辑
摘要: 第一步: 打开 Anaconda Prompt 第二步: 查看文件夹所在路径 例如:你有个jupyterwork文件夹在 D:\ 路径下 第三步: 在Anaconda Prompt依次输入一下命令: d: cd jupyterwork jupyter notebook 完成。 阅读全文
posted @ 2019-04-08 23:02 那是个好男孩 阅读(1723) 评论(0) 推荐(0) 编辑
摘要: 在VScode上面写的,现将代码粘贴如下:(在VScode里运行下即可) 阅读全文
posted @ 2019-03-26 15:57 那是个好男孩 阅读(433) 评论(0) 推荐(0) 编辑
摘要: import json import requests from requests.exceptions import RequestException import re import time def get_one_page(url): try: headers = { 'User-Agent': 'Mozilla/5.0 (Macint... 阅读全文
posted @ 2019-03-04 16:53 那是个好男孩 阅读(106) 评论(0) 推荐(0) 编辑
摘要: """ 匹配目标 """ # import re # content = 'Hello 123 4567 World_This is a Regex Demo' # result = re.match("^Hello\s(\d+)\sWorld$", content) # print(result.group(1)) """ 通用匹配 """ # import re # content = 'H... 阅读全文
posted @ 2019-02-27 21:17 那是个好男孩 阅读(132) 评论(0) 推荐(0) 编辑
摘要: """ requests """ # import requests # reponse = requests.get("https://www.baidu.com") # print(type(reponse)) # print(reponse.status_code) # print(type(reponse.text)) # print(reponse.text) # print(repo... 阅读全文
posted @ 2019-02-26 19:46 那是个好男孩 阅读(250) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 8 下一页