[Python] Frequently used method or solutions for issues
Web Scraping爬虫 for Mac urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>
Solution: if 1) does not work, then try to use 2). Reference is here.
1)
pip install --upgrade certifi
2)
open /Applications/Python\ 3.6/Install\ Certificates.command
if running a python file to use https call, have error like
"SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661"
Solution:
then solve it by adding
configuration.verify_ssl = False
in the test file.
Then it will skip verifying SSL certificate when calling API from https server.
if running a python file to use https call, have the warning of InsecureRequestWarning
Solution:
then solve it by adding
import urllib3
urllib3.disable_warnings()
in the test file.
Then it will skip warning.
- Remove leading whitespace 去除string前面的空格
Solution:
>>> ' hello world!'.lstrip()
'hello world!'
Web Scraping爬虫
看网页编码方式( 一般为“utf-8”)
Solution: F12功能键,即可使用开发者工具,在窗口console标签下,键入 "document.charset" 即可查看网页的编码方式
[Python] Frequently used method or solutions for issues的更多相关文章
- [JavaScript] Frequently used method or solutions for issues
Get the file name from the file path Solution: var fileName = fullPath.replace(/^.*[\\\/]/, ''); // ...
- [CSS] Frequently used method or solutions for issues
Stick button in right side in html Solution: //In the html <div class="float__button" & ...
- [Java] Frequently used method or solutions for issues
模板: Split string into parts based on new line in java Solution: Reference is here. 1) get out of t ...
- 关于Python的函数(Method)与方法(Function)
先上结论: 函数(function)是Python中一个可调用对象(callable), 方法(method)是一种特殊的函数. 一个可调用对象是方法和函数,和这个对象无关,仅和这个对象是否与类或实例 ...
- Python tricks(2) -- method默认参数和闭包closure
Python的method可以设置默认参数, 默认参数如果是可变的类型, 比如list, map等, 将会影响所有的该方法调用. 下面是一个简单的例子 def f(a=None, l=[]): if ...
- 2.Python函数/方法(method/function)详解
1.什么是函数 它是一段功能代码,理解为一种功能行为,在内存中有空间区域,函数需要被调用才能执行(通过函数名来调用): 好处: 1).提高代码的复用性 2).提升代码的阅读性 3).增加代码的扩展性 ...
- [Python] String strip() Method
Description The method strip() returns a copy of the string in which all chars have been stripped fr ...
- [Python] The get() method on Python dicts and its "default" arg
# The get() method on dicts # and its "default" argument name_for_userid = { 382: "Al ...
- Python String startswith() Method
一,摘自官方API https://docs.python.org/3/library/stdtypes.html#methods str.startswith(prefix[, start[, e ...
随机推荐
- 移动端H5混合开发,Touch触控,拖拽,长按, 滑屏 实现方案
概述 近期由于产品快速原型开发的需要,不想用原声的方式开发App两端一起搞时间来不及,目前产品处于大量上feature的阶段,采用混合开发是最合适的选择,所以花了3天的时间研究怎么去实现移动端,拖拽, ...
- Nodejs----简介
1.概述: Node.js是基于Chrome JavaScript运行时建立的一个平台,实际上它是对Google Chrome V8引擎进行了封装,它主要用于创建快速的.可扩展的网络应用.Node.j ...
- Redis----整理
--------------------------------------------------------------------redis--------------------------- ...
- 温故KMP算法
最近由于某些原因,又回顾了一次KMP算法.上一次回顾KMP算法还是在刷题的时候遇到的: http://blog.csdn.net/dacc123/article/details/50994611 在我 ...
- poj3376 Finding Palindromes【exKMP】【Trie】
Finding Palindromes Time Limit: 10000MS Memory Limit: 262144K Total Submissions:4710 Accepted: 8 ...
- 7.26-STOIRegularMatch-08-#14
A-3 SRM 08 描述 给一个 01 串设为其 S,询问是否存在只出现两次的 01 串 T. 这里的出现定义为存在一串下标 ,满足 且 . 输入格式 一行,一个 01 串 输出格式 一行,字母 ...
- 使用graalvm.js调用promise
前提 1.JDK1.8 2.引入jar包 <!--graalvm.js --> <dependency> <groupId>org.graalvm.js</g ...
- distributed computing_the World Wide Web
RESTful Web APIs_2013 I'm going to show you a better way to do distributed computing, using the idea ...
- python basic
#遍历一个序列,很多传统语言过来的,习惯用下标遍历,Python中序列是可迭代的,直接for即可! colors=['red','green','blue','yellow'] for color i ...
- Page12:镇定条件、镇定与极点配置的关系,解耦控制的概念等[Linear System Theory]
内容包含镇定条件.镇定与极点配置的关系,解耦控制的概念.形式.分类以及各种解耦方法特点,系统能否解耦判断.