摘要:
import requests #http://docs.python-requests.org/en/latest/api/ 说明文档 ''' requests.request(method,url,**kwargs) requests.head(url,**kwargs) requests.ge 阅读全文
posted @ 2018-08-28 14:47
庭明
阅读(662)
评论(0)
推荐(0)
摘要:
#!Python3 #-*- coding: utf-8 -*- #网页爬虫示例 用于抓取的示例网址http://example.webscraping.com ,搭建该网站的源代码 http://bitbucket.org/wswp/places ''' 准备着手抄写爬虫程序时,想到最近看的教程中 阅读全文
posted @ 2018-08-28 14:46
庭明
阅读(197)
评论(0)
推荐(0)
摘要:
import requests s=requests.Session() re=s.get(lgurl,headers=headers) #此处s可以直接换成requests the_page=re.content #content 为二进制文本 from lxml import etree htm 阅读全文
posted @ 2018-08-28 14:45
庭明
阅读(219)
评论(0)
推荐(0)
摘要:
URL的一般格式为(带方括号[]的为可选项): protocol :// hostname[:port] / path / [;parameters][?query]#fragment urllib.parse.urlparse会把URL解析成6部分 scheme://netloc/path;par 阅读全文
posted @ 2018-08-28 14:45
庭明
阅读(1507)
评论(0)
推荐(0)
摘要:
urllib.request 发送request和获取request的结果 urllib.error包含了urllib.request产生的异常 urllib.parse用来解析和处理Url urllib.robotparse用来解析页面的robots.txt文件 urllib.request.ur 阅读全文
posted @ 2018-08-28 14:44
庭明
阅读(547)
评论(0)
推荐(0)
摘要:
#!python3 #-*- coding:utf8 -*- #PyPDF2可能会打不开某些pdf文档,也不能提取图片,图表或者其他媒介从PDF文件中。但是它能提取文本从PDF中,转化为字符。 import PyPDF2 #以二进制方式 读模式打开一个pdf文件 pdfFileObj=open('e 阅读全文
posted @ 2018-08-28 14:43
庭明
阅读(631)
评论(0)
推荐(0)
摘要:
#! /usr/bin/env python3 # -*- coding:utf-8 -*- #TCP/IP简介 #为了把全世界的所有不同类型的计算机都连接起来,就必须规定一套全球通用的协议,为了实现互联网这个目标,互联网协议簇(Internet Protocol Suite)就是 #通用协议标准。 阅读全文
posted @ 2018-08-28 14:42
庭明
阅读(633)
评论(0)
推荐(0)
摘要:
#文档地址 http://api.mongodb.com/python/current/api/pymongo/collection.html collection级别的操作: find_and _modify(query={},update=None,upert=False,sort=None,f 阅读全文
posted @ 2018-08-28 14:40
庭明
阅读(215)
评论(0)
推荐(0)
摘要:
__contains__():对类实例使用in ,not in操作时调用 class A(object): def __init__(self,num): self.num=num def __contains__(self,item): print('__contains__: %s is in 阅读全文
posted @ 2018-08-28 14:39
庭明
阅读(243)
评论(0)
推荐(0)
摘要:
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #!/usr/bin/env python3 #-*- coding:utf-8 -*- #多线程 #多任务可以由多进程完成,也可以由一个进程内的多线程完成。 #进程是若干线程组成,一个进程至少有一个线程 阅读全文
posted @ 2018-08-28 14:36
庭明
阅读(250)
评论(0)
推荐(0)


浙公网安备 33010602011771号