Python爬取大量数据时防止被封IP

 

From:http://blog.51cto.com/7200087/2070320

基于scrapy框架的爬虫代理IP设置:https://www.jianshu.com/p/074c36a7948c

Scrapy: 针对特定响应状态码,使用代理重新请求:http://www.cnblogs.com/my8100/p/scrapy_middleware_autoproxy.html

Python爬虫技巧---设置代理IP:https://blog.csdn.net/lammonpeter/article/details/52917264

国内髙匿代理IP网站:http://www.xicidaili.com/nn/

Scrapy配置代理:https://www.jianshu.com/p/b21f94b8591c

Python网络爬虫--Scrapy使用IP代理池:https://www.jianshu.com/p/da94a2a24de8

scrapy设置代理池:https://blog.csdn.net/weixin_40475396/article/details/78241238

scrapy绕过反爬虫:https://www.imooc.com/article/35588

Scrapy学习笔记(7)-定制动态可配置爬虫:http://jinbitou.net/2016/12/05/2244.html

Python scrapy.http.HtmlResponse():https://www.programcreek.com/python/example/71413/scrapy.http.HtmlResponse

scrapy之随机设置请求头和ip代理池中间件:https://www.jianshu.com/p/ca1afe40bba3

 

 

在scrapy中使用代理,有两种使用方式

  1. 使用中间件
  2. 直接设置Request类的meta参数

 

方式一:使用中间件

要进行下面两步操作

  1. 在文件 settings.py 中激活代理中间件ProxyMiddleware
  2. 在文件 middlewares.py 中实现类ProxyMiddleware

1.文件 settings.py 中:

# settings.pyDOWNLOADER_MIDDLEWARES = {'project_name.middlewares.ProxyMiddleware': 100,    # 注意修改 project_name'scrapy.downloadermiddleware.httpproxy.HttpProxyMiddleware': 110,
}

说明
数字100, 110表示中间件先被调用的次序。数字越小,越先被调用。
官网文档:

The integer values you assign to classes in this setting determine the order in which they run: items go through from lower valued to higher valued classes. It’s customary to define these numbers in the 0-1000 range.

2.文件 middlewares.py 看起来像这样:

代理不断变换

  • 这里利用网上API 直接get过来。(需要一个APIKEY,免费注册一个账号就有了。这个APIKEY是我自己的,不保证一直有效!
  • 也可以从网上现抓。
  • 还可以从本地文件读取
# middlewares.pyimport requestsclass ProxyMiddleware(object):def process_request(self, request, spider):APIKEY = 'f95f08afc952c034cc2ff9c5548d51be'url = 'https://www.proxicity.io/api/v1/{}/proxy'.format(APIKEY) # 在线API接口r = requests.get(url)request.meta['proxy'] = r.json()['curl'] # 协议://IP地址:端口(如 http://5.39.85.100:30059)return request

方式二:直接设置Request类的meta参数

import random# 事先准备的代理池
proxy_pool = ['http://proxy_ip1:port', 'http://proxy_ip2:port', ..., 'http://proxy_ipn:port']class MySpider(BaseSpider):name = "my_spider"allowed_domains = ["example.com"]start_urls = ['http://www.example.com/articals/',]def start_requests(self):for url in self.start_urls:proxy_addr = random.choice(proxy_pool) # 随机选一个yield scrapy.Request(url, callback=self.parse, meta={'proxy': proxy_addr}) # 通过meta参数添加代理def parse(self, response):# doing parse

延伸阅读

1.阅读官网文档对Request类的描述,我们可以发现除了设置proxy,还可以设置method, headers, cookies, encoding等等:

class scrapy.http.Request(url[, callback, method='GET', headers, body, cookies, meta, encoding='utf-8', priority=0, dont_filter=False, errback])

2.官网文档对Request.meta参数可以设置的详细列表:

  • dont_redirect
  • dont_retry
  • handle_httpstatus_list
  • handle_httpstatus_all
  • dont_merge_cookies (see cookies parameter of Request constructor)
  • cookiejar
  • dont_cache
  • redirect_urls
  • bindaddress
  • dont_obey_robotstxt
  • download_timeout
  • download_maxsize
  • proxy

如随机设置请求头和代理:

# my_spider.pyimport random# 事先收集准备的代理池
proxy_pool = ['http://proxy_ip1:port', 'http://proxy_ip2:port',..., 'http://proxy_ipn:port'
]# 事先收集准备的 headers
headers_pool = [{'User-Agent': 'Mozzila 1.0'},{'User-Agent': 'Mozzila 2.0'},{'User-Agent': 'Mozzila 3.0'},{'User-Agent': 'Mozzila 4.0'},{'User-Agent': 'Chrome 1.0'},{'User-Agent': 'Chrome 2.0'},{'User-Agent': 'Chrome 3.0'},{'User-Agent': 'Chrome 4.0'},{'User-Agent': 'IE 1.0'},{'User-Agent': 'IE 2.0'},{'User-Agent': 'IE 3.0'},{'User-Agent': 'IE 4.0'},
]class MySpider(BaseSpider):name = "my_spider"allowed_domains = ["example.com"]start_urls = ['http://www.example.com/articals/',]def start_requests(self):for url in self.start_urls:headers = random.choice(headers_pool) # 随机选一个headersproxy_addr = random.choice(proxy_pool) # 随机选一个代理yield scrapy.Request(url, callback=self.parse, headers=headers, meta={'proxy': proxy_addr})def parse(self, response):# doing parse

 

 

记录一个比较完整的通过ip池进行爬虫被禁的处理

scrapy接入IP代理池(代码部分):https://blog.csdn.net/xudailong_blog/article/details/80153387

class HttpProxymiddleware(object):# 一些异常情况汇总EXCEPTIONS_TO_CHANGE = (defer.TimeoutError, TimeoutError, ConnectionRefusedError, ConnectError, ConnectionLost,TCPTimedOutError, ConnectionDone)def __init__(self):# 链接数据库 decode_responses设置取出的编码为strself.redis = redis.from_url('redis://:你的密码@localhost:6379/0',decode_responses=True)passdef process_request(self, request, spider):#拿出全部key,随机选取一个键值对keys = self.rds.hkeys("xila_hash")key = random.choice(keys)#用eval函数转换为dictproxy = eval(self.rds.hget("xila_hash",key))logger.warning("-----------------"+str(proxy)+"试用中------------------------")#将代理ip 和 key存入materequest.meta["proxy"] = proxy["ip"]request.meta["accountText"] = keydef process_response(self, request, response, spider):http_status = response.status#根据response的状态判断 ,200的话ip的times +1重新写入数据库,返回response到下一环节if http_status == 200:key = request.meta["accountText"]proxy = eval(self.rds.hget("xila_hash",key))proxy["times"] = proxy["times"] + 1self.rds.hset("xila_hash",key,proxy)return response#403有可能是因为user-agent不可用引起,和代理ip无关,返回请求即可elif http_status == 403:logging.warning("#########################403重新请求中############################")return request.replace(dont_filter=True)#其他情况姑且被判定ip不可用,times小于10的,删掉,大于等于10的暂时保留else:ip = request.meta["proxy"]key = request.meta["accountText"]proxy = eval(self.rds.hget("xila_hash", key))if proxy["times"] < 10:self.rds.hdel("xila_hash",key)logging.warning("#################" + ip + "不可用,已经删除########################")return request.replace(dont_filter=True)def process_exception(self, request, exception, spider):#其他一些timeout之类异常判断后的处理,ip不可用删除即可if isinstance(exception, self.EXCEPTIONS_TO_CHANGE) \and request.meta.get('proxy', False):key = request.meta["accountText"]print("+++++++++++++++++++++++++{}不可用+++将被删除++++++++++++++++++++++++".format(key))proxy = eval(self.rds.hget("xila_hash", key))if proxy["times"] < 10:self.rds.hdel("xila_hash", key)logger.debug("Proxy {}链接出错{}.".format(request.meta['proxy'], exception))return request.replace(dont_filter=True)

 

 

Scrapy 扩展中间件: 针对特定响应状态码,使用代理重新请求

 

0.参考

https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#module-scrapy.downloadermiddlewares.redirect

https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#module-scrapy.downloadermiddlewares.httpproxy

 

1.主要实现

实际爬虫过程中如果请求过于频繁,通常会被临时重定向到登录页面即302,甚至是提示禁止访问即403,因此可以对这些响应执行一次代理请求:

(1) 参考原生 redirect.py 模块,满足 dont_redirect 或 handle_httpstatus_list 等条件时,直接传递 response

(2) 不满足条件(1),如果响应状态码为 302 或 403,使用代理重新发起请求

(3) 使用代理后,如果响应状态码仍为 302 或 403,直接丢弃

 

2.代码实现

保存至 /site-packages/my_middlewares.py

from w3lib.url import safe_url_string
from six.moves.urllib.parse import urljoinfrom scrapy.exceptions import IgnoreRequestclass MyAutoProxyDownloaderMiddleware(object):def __init__(self, settings):self.proxy_status = settings.get(‘PROXY_STATUS‘, [302, 403])# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html?highlight=proxy#module-scrapy.downloadermiddlewares.httpproxyself.proxy_config = settings.get(‘PROXY_CONFIG‘, ‘http://username:password@some_proxy_server:port‘)@classmethoddef from_crawler(cls, crawler):return cls(settings = crawler.settings)        # See /site-packages/scrapy/downloadermiddlewares/redirect.pydef process_response(self, request, response, spider):if (request.meta.get(‘dont_redirect‘, False) orresponse.status in getattr(spider, ‘handle_httpstatus_list‘, []) orresponse.status in request.meta.get(‘handle_httpstatus_list‘, []) orrequest.meta.get(‘handle_httpstatus_all‘, False)):return responseif response.status in self.proxy_status:if ‘Location‘ in response.headers:location = safe_url_string(response.headers[‘location‘])redirected_url = urljoin(request.url, location)else:redirected_url = ‘‘# AutoProxy for first timeif not request.meta.get(‘auto_proxy‘):request.meta.update({‘auto_proxy‘: True, ‘proxy‘: self.proxy_config})new_request = request.replace(meta=request.meta, dont_filter=True)new_request.priority = request.priority + 2spider.log(‘Will AutoProxy for <{} {}> {}‘.format(response.status, request.url, redirected_url))return new_request# IgnoreRequest for second timeelse:spider.logger.warn(‘Ignoring response <{} {}>: HTTP status code still in {} after AutoProxy‘.format(response.status, request.url, self.proxy_status))raise IgnoreRequestreturn response

 

3.调用方法

(1) 项目 settings.py 添加代码,注意必须在默认的 RedirectMiddleware 和 HttpProxyMiddleware 之间。

# Enable or disable downloader middlewares
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {# ‘scrapy.downloadermiddlewares.redirect.RedirectMiddleware‘: 600,‘my_middlewares.MyAutoProxyDownloaderMiddleware‘: 601,# ‘scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware‘: 750,    
}
PROXY_STATUS = [302, 403]
PROXY_CONFIG = ‘http://username:password@some_proxy_server:port‘

 

4.运行结果

2018-07-18 18:42:35 [scrapy.core.engine] DEBUG: Crawled (200) <GET http://httpbin.org/> (referer: None)
2018-07-18 18:42:38 [test] DEBUG: Will AutoProxy for <302 http://httpbin.org/status/302> http://httpbin.org/redirect/1
2018-07-18 18:42:43 [test] DEBUG: Will AutoProxy for <403 https://httpbin.org/status/403>
2018-07-18 18:42:51 [test] WARNING: Ignoring response <302 http://httpbin.org/status/302>: HTTP status code still in [302, 403] after AutoProxy
2018-07-18 18:42:52 [test] WARNING: Ignoring response <403 https://httpbin.org/status/403>: HTTP status code still in [302, 403] after AutoProxy

 

代理服务器 log:

squid [18/Jul/2018:18:42:53 +0800] "GET http://httpbin.org/status/302 HTTP/1.1" 302 310 "-" "Mozilla/5.0" TCP_MISS:HIER_DIRECT
squid [18/Jul/2018:18:42:54 +0800] "CONNECT httpbin.org:443 HTTP/1.1" 200 3560 "-" "-" TCP_TUNNEL:HIER_DIRECT

 

 

 

Python爬虫技巧之设置代理IP

 

在学习Python爬虫的时候,经常会遇见所要爬取的网站采取了反爬取技术,高强度、高效率地爬取网页信息常常会给网站服务器带来巨大压力,所以同一个IP反复爬取同一个网页,就很可能被封,这里讲述一个爬虫技巧,设置代理IP。

 

(一)配置环境

  • 安装requests库
  • 安装bs4库
  • 安装lxml库

 

(二)代码展示

 

 

IP地址取自国内髙匿代理IP网站:http://www.xicidaili.com/nn/
仅仅爬取首页IP地址就足够一般使用

from bs4 import BeautifulSoup
import requests
import randomdef get_ip_list(url, headers):web_data = requests.get(url, headers=headers)soup = BeautifulSoup(web_data.text, 'lxml')ips = soup.find_all('tr')ip_list = []for i in range(1, len(ips)):ip_info = ips[i]tds = ip_info.find_all('td')ip_list.append(tds[1].text + ':' + tds[2].text)return ip_listdef get_random_ip(ip_list):proxy_list = []for ip in ip_list:proxy_list.append('http://' + ip)proxy_ip = random.choice(proxy_list)proxies = {'http': proxy_ip}return proxiesif __name__ == '__main__':url = 'http://www.xicidaili.com/nn/'headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'}ip_list = get_ip_list(url, headers=headers)proxies = get_random_ip(ip_list)print(proxies)
  1. 数get_ip_list(url, headers)传入url和headers,最后返回一个IP列表,列表的元素类似42.84.226.65:8888格式,这个列表包括国内髙匿代理IP网站首页所有IP地址和端口。
  2. 函数get_random_ip(ip_list)传入第一个函数得到的列表,返回一个随机的proxies,这个proxies可以传入到requests的get方法中,这样就可以做到每次运行都使用不同的IP访问被爬取的网站,有效地避免了真实IP被封的风险。proxies的格式是一个字典:{‘http’: ‘http://42.84.226.65:8888‘}。

 

(三)代理IP的使用

运行上面的代码会得到一个随机的proxies,把它直接传入requests的get方法中即可。

web_data = requests.get(url, headers=headers, proxies=proxies)

 

 

爬取猪八戒网信息

 

继续老套路,这两天我爬取了猪八戒上的一些数据 网址是:http://task.zbj.com/t-ppsj/p1s5.html,可能是由于爬取的数据量有点多吧,结果我的IP被封了,需要自己手动来验证解封ip,但这显然阻止了我爬取更多的数据了。

猪八戒IP 被封

下面是我写的爬取猪八戒的被封IP的代码

# coding=utf-8
import requests
from lxml import etreedef getUrl():for i in range(33):url = 'http://task.zbj.com/t-ppsj/p{}s5.html'.format(i+1)spiderPage(url)def spiderPage(url):if url is None:return NonehtmlText = requests.get(url).textselector = etree.HTML(htmlText)tds = selector.xpath('//*[@class="tab-switch tab-progress"]/table/tr')try:for td in tds:price = td.xpath('./td/p/em/text()')href = td.xpath('./td/p/a/@href')title = td.xpath('./td/p/a/text()')subTitle = td.xpath('./td/p/text()')deadline = td.xpath('./td/span/text()')price = price[0] if len(price)>0 else ''    # python的三目运算 :为真时的结果 if 判定条件 else 为假时的结果title = title[0] if len(title)>0 else ''href = href[0] if len(href)>0 else ''subTitle = subTitle[0] if len(subTitle)>0 else ''deadline = deadline[0] if len(deadline)>0 else ''print price,title,href,subTitle,deadlineprint '---------------------------------------------------------------------------------------'spiderDetail(href)except:print '出错'def spiderDetail(url):if url is None:return Nonetry:htmlText = requests.get(url).textselector = etree.HTML(htmlText)aboutHref = selector.xpath('//*[@id="utopia_widget_10"]/div[1]/div/div/div/p[1]/a/@href')price = selector.xpath('//*[@id="utopia_widget_10"]/div[1]/div/div/div/p[1]/text()')title = selector.xpath('//*[@id="utopia_widget_10"]/div[1]/div/div/h2/text()')contentDetail = selector.xpath('//*[@id="utopia_widget_10"]/div[2]/div/div[1]/div[1]/text()')publishDate = selector.xpath('//*[@id="utopia_widget_10"]/div[2]/div/div[1]/p/text()')aboutHref = aboutHref[0] if len(aboutHref) > 0 else ''  # python的三目运算 :为真时的结果 if 判定条件 else 为假时的结果price = price[0] if len(price) > 0 else ''title = title[0] if len(title) > 0 else ''contentDetail = contentDetail[0] if len(contentDetail) > 0 else ''publishDate = publishDate[0] if len(publishDate) > 0 else ''print aboutHref,price,title,contentDetail,publishDateexcept:print '出错'if '_main_':getUrl()

我发现代码运行完后,后面有几页数据没有被爬取,我再也没有办法去访问猪八戒网站了,等过了一段时间才能去访问他们的网站,这就很尴尬了,我得防止被封IP

如何防止爬取数据的时候被网站封IP这里有一些套路.查了一些套路

1.修改请求头

之前的爬虫代码没有添加头部,这里我添加了头部,模拟成浏览器去访问网站

        user_agent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.4295.400'headers = {'User-Agent': user_agent}htmlText = requests.get(url, headers=headers, proxies=proxies).text

2.采用代理IP

当自己的ip被网站封了之后,只能采用代理ip的方式进行爬取,所以每次爬取的时候尽量用代理ip来爬取,封了代理还有代理。

这里我引用了这个博客的一段代码来生成ip地址:http://blog.csdn.net/lammonpeter/article/details/52917264

生成代理ip,大家可以直接把这个代码拿去用

# coding=utf-8
# IP地址取自国内髙匿代理IP网站:http://www.xicidaili.com/nn/
# 仅仅爬取首页IP地址就足够一般使用from bs4 import BeautifulSoup
import requests
import randomdef get_ip_list(url, headers):web_data = requests.get(url, headers=headers)soup = BeautifulSoup(web_data.text, 'lxml')ips = soup.find_all('tr')ip_list = []for i in range(1, len(ips)):ip_info = ips[i]tds = ip_info.find_all('td')ip_list.append(tds[1].text + ':' + tds[2].text)return ip_listdef get_random_ip(ip_list):proxy_list = []for ip in ip_list:proxy_list.append('http://' + ip)proxy_ip = random.choice(proxy_list)proxies = {'http': proxy_ip}return proxiesif __name__ == '__main__':url = 'http://www.xicidaili.com/nn/'headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'}ip_list = get_ip_list(url, headers=headers)proxies = get_random_ip(ip_list)print(proxies)

好了我用上面的代码给我生成了一批ip地址(有些ip地址可能无效,但只要不封我自己的ip就可以了,哈哈),然后我就可以在我的请求头部添加ip地址

给我们的请求添加代理ip

        proxies = {'http': 'http://124.72.109.183:8118','http': 'http://49.85.1.79:31666'}user_agent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.4295.400'headers = {'User-Agent': user_agent}htmlText = requests.get(url, headers=headers, timeout=3, proxies=proxies).text

目前知道的就

最后完整代码如下:


# coding=utf-8import requests
import time
from lxml import etreedef getUrl():for i in range(33):url = 'http://task.zbj.com/t-ppsj/p{}s5.html'.format(i+1)spiderPage(url)def spiderPage(url):if url is None:return Nonetry:proxies = {'http': 'http://221.202.248.52:80',}user_agent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.4295.400'headers = {'User-Agent': user_agent}htmlText = requests.get(url, headers=headers,proxies=proxies).textselector = etree.HTML(htmlText)tds = selector.xpath('//*[@class="tab-switch tab-progress"]/table/tr')for td in tds:price = td.xpath('./td/p/em/text()')href = td.xpath('./td/p/a/@href')title = td.xpath('./td/p/a/text()')subTitle = td.xpath('./td/p/text()')deadline = td.xpath('./td/span/text()')price = price[0] if len(price)>0 else ''    # python的三目运算 :为真时的结果 if 判定条件 else 为假时的结果title = title[0] if len(title)>0 else ''href = href[0] if len(href)>0 else ''subTitle = subTitle[0] if len(subTitle)>0 else ''deadline = deadline[0] if len(deadline)>0 else ''print price,title,href,subTitle,deadlineprint '---------------------------------------------------------------------------------------'spiderDetail(href)except Exception,e:print '出错',e.messagedef spiderDetail(url):if url is None:return Nonetry:htmlText = requests.get(url).textselector = etree.HTML(htmlText)aboutHref = selector.xpath('//*[@id="utopia_widget_10"]/div[1]/div/div/div/p[1]/a/@href')price = selector.xpath('//*[@id="utopia_widget_10"]/div[1]/div/div/div/p[1]/text()')title = selector.xpath('//*[@id="utopia_widget_10"]/div[1]/div/div/h2/text()')contentDetail = selector.xpath('//*[@id="utopia_widget_10"]/div[2]/div/div[1]/div[1]/text()')publishDate = selector.xpath('//*[@id="utopia_widget_10"]/div[2]/div/div[1]/p/text()')aboutHref = aboutHref[0] if len(aboutHref) > 0 else ''  # python的三目运算 :为真时的结果 if 判定条件 else 为假时的结果price = price[0] if len(price) > 0 else ''title = title[0] if len(title) > 0 else ''contentDetail = contentDetail[0] if len(contentDetail) > 0 else ''publishDate = publishDate[0] if len(publishDate) > 0 else ''print aboutHref,price,title,contentDetail,publishDateexcept:print '出错'if '_main_':getUrl()

最后程序完美运行,再也没有出现被封IP的情况。当然防止被封IP肯定不止这些了,这还需要进一步探索!

最后

当然数据我是已经抓取过来了,但是我的数据都没有完美呈现出来,我应该写入execl文件,或者数据库中啊,这样才能方便采用.所以接下来我准备了使用
Python操作execl,mysql,mongoDB

 

 

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/496133.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

c语言错误c4430,声明*C某类::Getdocument();(已声明,不兼容)

创建了一个CRightWindow类&#xff0c;基类为CScrollView&#xff0c;在.h文件中如下&#xff1a;public:CMy2015Doc* GetDocument(); // error C2143: 语法错误 : 缺少“;”(在“*”的前面)// error C4430: 缺少类型说明符 – 假定为 int。注意: C 不支持默认 int在…

CollapsiblePanel控件

CollapsiblePanel 控件属性将被初始化如下面的示例代码所示&#xff0c;斜体属性为可选属性。 <ajaxToolkit:CollapsiblePanelExtender ID"cpe" runat"Server"TargetControlID"Panel1"CollapsedSize"0"ExpandedSize"300"…

Effective Java~45. 谨慎使用Stream

在 Java 8 中添加了 Stream API&#xff0c;以简化顺序或并行执行批量操作的任务。 该 API 提供了两个关键的抽象&#xff1a;流(Stream)&#xff0c;表示有限或无限的数据元素序列&#xff0c;以及流管道 (stream pipeline)&#xff0c;表示对这些元素的多级计算。 Stream 中的…

shell 中 $(( )) 与 $( ) 还有 ${ } 的区别

From&#xff1a;http://blog.chinaunix.net/uid-14351756-id-2820651.html $( ) 与 (反引号) 在 bash shell 中&#xff0c;$( ) 与 (反引号) 都是用来做命令替换用(command substitution)的。 所谓的命令替换与我们第五章学过的变量替换差不多&#xff0c;都是用来重组命…

最近发包给朋友,搞定软件小活儿、解决小功能模块的感受

有时候也想&#xff0c;所有的事情都靠自己解决&#xff0c;太辛苦了太累了&#xff0c;在不差钱的这个年代&#xff0c;有些能让别人做的事情&#xff0c;就让别人做吧&#xff0c;但是一直找不到合适的人&#xff0c;什么叫合适的人&#xff1f;我简单的说几下&#xff0c;不…

c语言数列偶数在奇数前面,奇数

奇偶校验2021-05-19 15:03:06奇偶校验(Parity Check)是一种校验代码传输正确性的方法。根据被传输的一组二进制代码的数位中“1”的个数是奇数或偶数来进行校验。采用奇数的称为奇校验&#xff0c;反之&#xff0c;称为偶校验。奇偶校验需要一位校验位&#xff0c;即使用串口通…

利用自定义web-font实现数据防采集

From&#xff1a;https://blog.csdn.net/fdipzone/article/details/68166388 完整源码&#xff1a;https://download.csdn.net/download/fdipzone/9798142 web-font介绍 web-font 是 CSS3 中的一种标记 font-face&#xff0c;在 font-face 声明里&#xff0c;你可以声明一种字…

数字证书~证书链

来源&#xff1a;客户端认证https服务端证书过程详解——证书链_huzhenv5的博客-CSDN博客_证书链认证过程 基本概念 证书 首先&#xff0c;我们看看在wikipedia上对证书的定义&#xff0c;In cryptography, a public key certificate (also known as a digital certificate o…

修改Netbeas的注释结构

Eclipse修改注释的方法&#xff1a;  窗口-》首选项-》java-》代码样式-》代码模板-》注释-》方法-》确定&#xff0c;下面就可以修改了  Netbeans修改注释的方法&#xff1a;  工具->模板 打开 看见那一排列表没有 展开Java 选择Java类 点击 在编辑器中打开 …

c语言assign用法,object-c语言的nonatomic,assign,copy,retain的区别

nonatomic&#xff1a;非原子性访问&#xff0c;不加同步&#xff0c;多线程并发访问会提高性能。如果不加此属性&#xff0c;则默认是两个访问方法都为原子型事务访问。(atomic是Objc使用的一种线程保护技术&#xff0c;基本上来讲&#xff0c;是防止在写未完成的时候被另外一…

反反爬技术,破解猫眼网加密数字

From&#xff1a;https://blog.csdn.net/qq_31032181/article/details/79153578 From&#xff1a;http://www.freebuf.com/news/140965.html 利用自定义web-font实现数据防采集&#xff1a;http://blog.csdn.net/fdipzone/article/details/68166388 利用前端字体文件(.ttf)混…

数字签名,数字证书,证书链原理

来源&#xff1a;数字签名&#xff0c;数字证书&#xff0c;证书链原理&#xff08;图文详解&#xff09;_Ruby丶彬的博客-CSDN博客_证书链验证原理 数字签名&#xff0c;数字证书&#xff0c;加密简述 数字签名&#xff1a;谈及数字签名&#xff0c;就如小时候老师叫把卷子或…

成都信息工程c语言题库,成都信息工程学院C语言考试题及答案

}in 0;while (sum < im) { }sum - in; in--;printf(\sum%d\\n\in , sum); return 0;in; sum in;编写一程序P215.C实现以下功能求S1/1&#xff01;1/2&#xff01;1/3&#xff01;…1/N&#xff01;并输出结果(显示时小数部分占16位&#xff0c;计算时要求从第1项开始往后累…

转--javascript 数组

较为上篇更为深刻 原文&#xff1a;http://blog.csdn.net/jaylongli/archive/2009/03/20/4007823.aspx 数组有四种定义的方式 使用构造函数&#xff1a; vara newArray(); varb newArray(8); varc newArray("first", "second", "third"); 或者数…

猫眼 — 破解数字反爬获取实时票房

From&#xff1a;https://zhuanlan.zhihu.com/p/33112359 js分析 猫_眼_电_影 字体文件 font-face&#xff1a;https://www.cnblogs.com/my8100/p/js_maoyandianying.html 解析某电影和某招聘网站的web-font自定义字体&#xff1a;https://www.jianshu.com/p/5400bbc8b634 Fo…

c语言中单精度的有效位数是,C语言中的单精度双精度数的有效位数

#include "stdio.h"#include "conio.h"void main(){printf("%.20f\n",0.1234567890123456789f);getch();}观察在VC6&#xff0c;WinTC中的运行结果&#xff0c;可能是0.1234567891043281560000.12345678901234567700而一般在C语言教材上说&#…

Yoshua Bengio团队通过在网络「隐藏空间」中使用降噪器以提高深度神经网络的「鲁棒性」

原文来源&#xff1a;arXiv 作者&#xff1a;Alex Lamb、Jonathan Binas、Anirudh Goyal、Dmitriy Serdyuk、Sandeep Subramanian、Ioannis Mitliagkas、Yoshua Bengio「雷克世界」编译&#xff1a;嗯~是阿童木呀、KABUDA、EVA导语&#xff1a;深度神经网络在各种各样的重要任…

PDF签名系列(1):PDF签名机制的漏洞分析

来源&#xff1a;PDF签名系列(1):PDF签名机制的漏洞分析 - 知乎 研究PDF文件的签名机制有一段时间了&#xff0c;刚开始学习的时候就看到有提到说&#xff0c;被签名的PDF内容的Range gap&#xff0c;会成为这个机制的漏洞&#xff0c;但是一直不能完全参透。直到昨天看到一篇…

linux date命令显示毫秒,解决MacOS系统中date命令没有毫秒和sha512sum、sha256sum、md5sum等命令的问题...

安装brew/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"使用brew安装coreutilsbrew install coreutils设置系统新的命令软连接sudo ln -sv /usr/local/bin/gsha256sum /usr/local/bin/sha256sumsudo ln -sv /…

PDF签名系列(2):PDF的签名值到底存在哪里?

来源&#xff1a;PDF签名系列(2):PDF的签名值到底存在哪里? - 知乎 研究过PDF签名的同学应该见过下面这张图, 来自ADOBE的文档Acrobat_DigitalSignatures_in_PDF.pdf PDF被签名的内容是整个文档除去signature dictionary里/Contents下面的内容. 签过名的哈希值再连同其他一些…