如何检测网站上的变化? python网页抓取

时间:2021-01-13 00:03:08

标签: python web-scraping beautifulsoup python-requests

我开始为一个鞋类网站做一个监视器 python。现在我想知道是否有办法知道网站何时更新。例如:如果可用鞋码发生变化 -> 将 webhook 发送到我的不和谐处

我不知道如何检测网站上的更改.. 请帮助我。如果您有想法,请告诉我:)

img webhook discord

from dhooks import Webhook, Embed
import requests
import bs4
from bs4 import BeautifulSoup
import lxml

url = "https://en.aw-lab.com/women/shoes/new-arrivals-AW_10008AAQB.html?cgid=women_shoes_newin&dwvar_AW__10008AAQB_color=5011614"

headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}

res = requests.get(url, headers=headers)
res.raise_for_status()
soup = BeautifulSoup(res.text, "lxml")
img_shoes = "https://en.aw-lab.com/dw/image/v2/BCLG_PRD/on/demandware.static/-/Sites-awlab-master-catalog/default/dwd9415a8e/images/large/5011614_0.jpg?sw=843"
size = soup.select(".b-size-selector__item-0")
array_size = []

url_shoes = "[ADIDAS SUPERSTAR BOLD](" + url + ")"

embed = Embed(
    description=url_shoes,
    color=0x5CDBF0,
    timestamp='now'
)

for sizes in size:
    get_sizes = sizes.getText()
    array_size.append(get_sizes.strip())


embed.add_field(name="Size", value=('\n'.join(map(str, array_size))))

embed.set_thumbnail(img_shoes)

hook.send(embed=embed)

0 个答案:

没有答案