代码拉取完成,页面将自动刷新
import requests
from urllib.parse import quote
# 价格动态
from bs4 import BeautifulSoup
from database.RedisHelper import RedisHelper
from entity.Keys import Keys
from entity.ListPage import ListPage
from libs.SeleniumHelper import SeleniumHelper
redis_helper=RedisHelper()
cr = SeleniumHelper()
# keys =['客厅灯']
ks = Keys()
keys = ks.getKeys()
for item in keys:
key= quote(item)
url='https://search.suning.com/'+key+'/'
lp = ListPage()
text =lp.getPage(url)
lis = lp.getList(text)
for item in lis:
try:
price = cr.findPrice('https:'+item)
pre_price=redis_helper.get('cc:' + item)
# print(type(pre_price))
if pre_price != None:
if price<pre_price*0.2:
print('价格异常')
print(item)
if price == pre_price:
print('same price')
redis_helper.set('cc:'+item,price)
except Exception as e:
print(e)
# break
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。