[toc] 很多网站会监测一段时间内某个IP访问的次数(通过数据流量和日志等),如果访问的次数多的不像正常人,它就会把这个IP地址封了。所以我们就需要设置一些代理服务器,每隔一段时间换一个代理,就算IP被禁止,依然可以换个IP继续爬。 常用的代理服务器: 西刺免费代理IP:https://www.x ...
分类:
编程语言 时间:
2020-03-25 19:39:40
阅读次数:
75
爬虫所需要的功能,基本上在urllib中都能找到,学习这个标准库,可以更加深入的理解后面更加便利的requests库。 首先 在Pytho2.x中使用import urllib2——-对应的,在Python3.x中会使用import urllib.request,urllib.error 在Pyth ...
分类:
编程语言 时间:
2020-03-25 10:54:09
阅读次数:
93
https://www.programcreek.com/python/example/59427/urllib.request.Request https://docs.python.org/3.5/library/urllib.request.html#urllib.request.Reques ...
分类:
Web程序 时间:
2020-03-25 10:44:06
阅读次数:
71
一个简单的爬虫案例 from scrapy_redis.spiders import RedisSpider import os,urllib.request,time class XiaohuaSpider(scrapy.Spider): name = 'xiaohua' allowed_doma ...
分类:
其他好文 时间:
2020-03-25 10:24:41
阅读次数:
58
# 1.导入urllib中的request # 2.定义爬取的url(统一资源定位符) # 3.定义一个请求对象request # request的参数有url:访问的网址;data:发起请求时带的数据请求方式为post; # headers:包括发送HTTP报文的键值对(例如user-agent请 ...
分类:
Web程序 时间:
2020-03-23 15:20:29
阅读次数:
79
# 使用parse对网址进行拼接操作 from urllib import request,parse base_url = 'https://www.baidu.com/s?' wd = input('请输入查询信息>>') query_msg = { 'wd':wd } msg = parse. ...
分类:
Web程序 时间:
2020-03-23 15:15:27
阅读次数:
78
1 from urllib import request,parse 2 import os 3 # https://tieba.baidu.com/f?kw=lol&ie=utf-8&pn=0 4 # https://tieba.baidu.com/f?kw=lol&ie=utf-8&pn=50 ...
分类:
Web程序 时间:
2020-03-23 15:01:56
阅读次数:
82
from urllib import request url = 'http://httpbin.org/ip' #使用代理 #1.使用ProxyHandler构建一个hander handler = request.ProxyHandler({ "HTTP":"182.35.84.11:9999" ...
分类:
编程语言 时间:
2020-03-22 16:11:07
阅读次数:
84
import requests from bs4 import BeautifulSoup import time import os import urllib #需要爬取的目标网页 link='https://www.zhihu.com/hot' #对网页进行解析 soup=BeautifulS ...
分类:
其他好文 时间:
2020-03-20 11:10:29
阅读次数:
75
from urllib import parse host = 'http://api.nnzhp.cn/' login_url = '/api/login' goods_urls = '/api/goods' new_url = parse.urljoin(host,login_url) # 拼u ...
分类:
Web程序 时间:
2020-03-18 15:20:28
阅读次数:
68