import urllib.request,http.cookiejar,urllib.parse,re print('start to login')url='http://www.renren.com/PLogin.do'logindomain='renren.com' user_agent=' ...
分类:
其他好文 时间:
2017-04-13 11:52:09
阅读次数:
156
try: import urllib.request as urllib2 except ImportError: import urllib2 response = urllib2.urlopen("http://www.baidu.com") print(response.getcode()) ...
分类:
编程语言 时间:
2017-04-12 22:52:17
阅读次数:
225
#需求:生成器的应用 #然后每次g.send(url),打印页面内容,利用g可以无限send 1 from urllib.request import urlopen #导入爬虫模块 2 def get(): 3 while True: 4 url = yield #将函数改成协程函数 5 prin... ...
分类:
Web程序 时间:
2017-04-12 20:37:07
阅读次数:
175
问题: urllib.request.urlopen() 方法经常会被用来打开一个网页的源代码,然后会去分析这个页面源代码,但是对于有的网站使用这种方法时会抛出"HTTP Error 403: Forbidden"异常 例如 执行下面的语句时 [python] <span style="font-s ...
分类:
Web程序 时间:
2017-04-11 11:12:36
阅读次数:
178
python使用代理访问服务器主要有一下3个步骤: 1.创建一个代理处理器ProxyHandler: proxy_support = urllib.request.ProxyHandler(),ProxyHandler是一个类,其参数是一个字典:{ '类型':'代理ip:端口号'} 什么是Handl ...
分类:
编程语言 时间:
2017-04-11 11:03:33
阅读次数:
213
1 import urllib.request 2 import os 3 4 def open_url(url): 5 req=urllib.request.Request(url) 6 req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.... ...
分类:
其他好文 时间:
2017-04-10 22:18:16
阅读次数:
253
# encoding:utf8import requests # Requests 是用Python语言编写,基于 urllib,采用 Apache2 Licensed 开源协议的 HTTP 库。它比 urllib 更加方便,可以节约我们大量的工作,完全满足 HTTP 测试需求。from lxml ...
分类:
其他好文 时间:
2017-04-10 20:29:11
阅读次数:
298
urllib 和urllib2都是接受URL请求的相关模块,但是提供了不同的功能.两个最显著的不同如下 urllib2 can accept a Request object to set the headers for a URL request,urllib accepts only a URL ...
分类:
Web程序 时间:
2017-04-10 19:14:15
阅读次数:
184
简介:Requests 是用Python语言编写,基于 urllib,采用 Apache2 Licensed 开源协议的 HTTP 库。它比 urllib 更加方便,可以节约我们大量的工作,完全满足 HTTP 测试需求。Requests 的哲学是以 PEP 20 的习语为中心开发的,所以它比 url ...
分类:
编程语言 时间:
2017-04-10 19:10:51
阅读次数:
10097
import base64 from datetime import datetime import json import os import urllib.request import wave import webbrowser import pyaudio import re CHUNK = ...
分类:
其他好文 时间:
2017-04-09 16:55:25
阅读次数:
337