随着苹果iPhone 13发布会的日益临近,有海外网友曝光了其中iPhone 13的详细配置,首先正面屏幕刘海大幅缩小,刘海内部的结构排列方式重新调整,听筒也会被挪到顶部边框的位置,以此来减小刘海面积。搭载自研A15仿生芯片,采用第二代5nm工艺,将会有效提升能效比,同时支持5G和WiFi6E标准。电池配备了3095mAh,续航水平将会得到明显提升,与此同时还进一步升级了快充,支持25W快速充电。因为iPhone 13的冲击,当前正在售卖的iPhone 12系列引发了价格大跳水。
如何才能抢购到心仪的手机呢,下面的demo演示了通过爬虫代理快速模拟多个终端发起请求的过程,在需要下单的电商网站可以试试哦:
代码语言:python代码运行次数:0复制 #! -*- encoding:utf-8 -*-
import urllib2
import random
import httplib
class HTTPSConnection(httplib.HTTPSConnection):
def set_tunnel(self, host, port=None, headers=None):
httplib.HTTPSConnection.set_tunnel(self, host, port, headers)
if hasattr(self, 'proxy_tunnel'):
self._tunnel_headers['Proxy-Tunnel'] = self.proxy_tunnel
class HTTPSHandler(urllib2.HTTPSHandler):
def https_open(self, req):
return urllib2.HTTPSHandler.do_open(self, HTTPSConnection, req, context=self._context)
# 要访问的目标页面
targetUrlList = [
"https://item.jd.com/100009077475.html#crumb-wrap",
"https://item.jd.com/100016034378.html#crumb-wrap",
"https://item.jd.com/100011203359.html#crumb-wrap",
]
# 代理服务器(产品官网 www.16yun.cn)
proxyHost = "t.16yun.cn"
proxyPort = "31111"
# 代理验证信息
proxyUser = "username"
proxyPass = "password"
proxyMeta = "http://%(user)s:%(pass)s@%(host)s:%(port)s" % {
"host": proxyHost,
"port": proxyPort,
"user": proxyUser,
"pass": proxyPass,
}
# 设置 http和https访问都是用HTTP代理
proxies = {
"http": proxyMeta,
"https": proxyMeta,
}
# 设置IP切换头
tunnel = random.randint(1, 10000)
headers = {"Proxy-Tunnel": str(tunnel)}
HTTPSConnection.proxy_tunnel = tunnel
proxy = urllib2.ProxyHandler(proxies)
opener = urllib2.build_opener(proxy, HTTPSHandler)
urllib2.install_opener(opener)
# 访问三次网站,使用相同的tunnel标志,均能够保持相同的外网IP
for i in range(3):
for url in targetUrlList:
r = urllib2.Request(url)
print(urllib2.urlopen(r).read())