python多线程爬虫:亚马逊价格
import re
import requests import threading
import time
from time import ctime,sleep from queue import Queue keywords_a=[
'ELPLP80',
'ELPLP23',
'ELPLP29',
'NP14LP',
'POA-LMP126',
'ELPLP66',
] keywords_b=[
'VIP230W0.8E20.8',
'VIP240W0.8E20.9N',
'NP30LP',
'LMP-C162',
'VT70LP',
] keywords_c= [
'TLPLV4',
'POA-LMP131',
'BL-FP240A',
'VLT-XD3200LP',
'ET-LAD35',
'BL-FU240A',
'20-01032-20', ] keywords_d =[
'ELPLP76',
'VLT-HC3800LP',
'BL-FP240C',
'5811116765-S',
'ELPLP69',
'BL-FP200H', ] keywords_e = [
'5100MP',
'RLC-057',
'ELPLP71',
'ELPLP64',
'BL-FS300B',
] Re_rule = '<span class="a-size-base a-color-price s-price a-text-bold">(.*?)</span>' #正则表达式匹配价格 headers_am = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.86 Safari/537.36'}
#浏览器页面headers
def Scraper(kw):
for i in kw:
url_keyword = 'https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords={}'.format(i)
#亚马逊页面链接
url_Epharos = 'http://www.amazon.com/s/ref=nb_sb_noss?url=srs%3D9143518011%26search-alias%3Dspecialty-aps&field-keywords={}'.format(i)
#店铺链接
response = requests.get(url_keyword,headers=headers_am)
#requests.get(url,params=params) 可以提交表单用request.post(url,params=params)
response_a = requests.get(url_Epharos,headers=headers_am)
price = re.findall(Re_rule,response.text)
price_e = re.findall(Re_rule,response_a.text) print('--------------------------{0}爬去完毕at{1}j结果:\n\n市场价:{2}\n\nEpharos:{3}'.format(i,time.ctime(),price[0],price_e[0]))
time.sleep(1) threads = [] t1 = threading.Thread(target=Scraper,args=(keywords_a,)) #args为元祖
threads.append(t1)
t2 = threading.Thread(target=Scraper,args=(keywords_b,))
threads.append(t2)
t3 = threading.Thread(target=Scraper,args=(keywords_c,))
threads.append(t3)
t4 = threading.Thread(target=Scraper,args=(keywords_d,))
threads.append(t4)
t5 = threading.Thread(target=Scraper,args=(keywords_e,))
threads.append(t5) if __name__ == '__main__':
for t in threads:
t.setDaemon(True) #守护线程
t.start()
for t in threads:
t.join() #等待子线程 print ("all over %s" %ctime())
python多线程爬虫:亚马逊价格的更多相关文章
- 爬虫亚马逊Bestselling类别产品数据TOP100
1 # -*- coding: utf-8 -*- 2 # @Time : 2020/9/11 16:23 3 # @Author : Chunfang 4 # @Email : 3470959534 ...
- python 脚本开发实战-当当亚马逊图书采集器转淘宝数据包
开发环境python2.7.9 os:win-xp exe打包工具pyinstaller 界面tkinter ============================================= ...
- 基于Java实现简单亚马逊爬虫
前言:最近博主买了台Kindle,感觉亚马逊上的图书资源质量挺好,还时不时地会有价格低但质量高的书出售,但限于亚马逊并没有很好的优惠提醒功能,自己天天盯着又很累.于是,我自己写了一个基于Java的亚马 ...
- 个性化对待亚马逊不同站点 使用 Python 进行线程编程
# -*- coding: UTF-8 -*- import threading import time exitFlag = 0 class myThread (threading.Thread): ...
- 使用pushplus+python实现亚马逊到货消息推送微信
xbox series和ps5发售以来,国内黄牛价格一直居高不下.虽然海外amazon上ps5补货很少而且基本撑不过一分钟,但是xbox series系列明显要好抢很多. 日亚.德亚的xbox ser ...
- 亚马逊商品页面的简单爬取 --Pyhon网络爬虫与信息获取
1.亚马逊商品页面链接地址(本次要爬取的页面url) https://www.amazon.cn/dp/B07BSLQ65P/ 2.代码部分 import requestsurl = "ht ...
- 如何使用代理IP进行数据抓取,PHP爬虫抓取亚马逊商品数据
什么是代理?什么情况下会用到代理IP? 代理服务器(Proxy Server),其功能就是代用户去取得网络信息,然后返回给用户.形象的说:它是网络信息的中转站.通过代理IP访问目标站,可以隐藏用户的真 ...
- python requests库网页爬取小实例:亚马逊商品页面的爬取
由于直接通过requests.get()方法去爬取网页,它的头部信息的user-agent显示的是python-requests/2.21.0,所以亚马逊网站可能会拒绝访问.所以我们要更改访问的头部信 ...
- JAVA爬取亚马逊的商品信息
在程序里面输入你想爬取的商品名字,就可以返回这件商品在亚马逊搜索中都所有相关商品的信息,包括名字和价格. 解决了在爬取亚马逊时候,亚马逊可以识别出你的爬虫,并返回503,造成只能爬取几个页面的问题. ...
随机推荐
- unity GPU bound or CPU bound
unity判断GPU CPUbound android 用unity profiler 里面的cpu时间 xcode有直接的显示
- Namenode 没启动
内容来源:http://blog.csdn.net/love666666shen/article/details/74350358 Question:多次格式化文件系统导致datanode无法启动 R ...
- javascript => 方法的简写形式
https://segmentfault.com/a/1190000002904199 => 是function的简写形式,支持expression 和 statement 两种形式.同时一点很 ...
- [Spring boot] Application properties and configurations
We can use different application properties application.properties: server.port=9090 application-pro ...
- 几个opengl立方体绘制案例
VC6 下载 http://blog.csdn.net/bcbobo21cn/article/details/44200205 opengl环境配置 http://blog.csdn.net/bcbo ...
- 网络编程——The C10K Problem(C10K = connection 10 kilo 问题)。k 表示 kilo,即 1000
The C10K problem翻译 (C10K = connection 10 kilo 问题).k 表示 kilo,即 1000 比如:kilometer(千米), kilogram(千克). 如 ...
- C++11 新特性之 变长參数模板
template <typename ... ARGS> void fun(ARGS ... args) 首先明白几个概念 1,模板參数包(template parameter pack) ...
- C-C Primer Plus阅读笔记
常用头: stdio.h string.h inttypes.h limits.h float.h 1.打印short.long.long long和unsigned #include <std ...
- ubuntu14.04 flash driver 安装
直接将14.04镜像直接放到flash driver 中 然后在bios设置flash driver 优先启动 然后格出一块盘给ubuntu 安装使用 按操作要求一路点下去就可以,记得选windows ...
- Atitit.跨语言 文件夹与文件的io操作集合 草案
Atitit.跨语言 文件夹与文件的io操作集合 草案 1. Jdk原生的太难用了..1 2. PS: apache commons-io包,FileUtils有相关的方法,IOUtils一般是拷 ...