Skip to content Skip to sidebar Skip to footer

Just Execute An IF Until The Value Is Changed Scraping

I am trying to scrape a web page to analyze the stock of some shoes, I did it as I would like but I would need to add one thing, and that is, for example, when suddenly there is a

Solution 1:

You can create a boolean value that becomes True when you send the webhook, and then look for this value to be false in order to send the email. The code would be something like this:

if not "OUT_OF_STOCK" in disponibilidad3[numero] and not enviado:
    
    enviado = True    
    hook = Webhook('')
    embed = Embed(
    color=15105570,
    timestamp='now'  # sets the timestamp to current time
    )

    embed.url = (url)
    embed.title = (nombre+" " + color)
    embed.add_field(name='Talla', value="["+tallas3[numero]+"]("+api+skus5[numero]+")")
    embed.add_field(name='Precio', value=precio)
    embed.add_field(name='Useful Links', value="[Checkout](https://www.zalando.es/checkout/confirm)", inline=False)
    
    embed.set_footer(text='Zalando by SilverPings', icon_url="https://assets.stickpng.com/thumbs/5a32a860cb9a85480a628f95.png")

    embed.set_thumbnail(imagen)

    hook.send(embed=embed)
    print("[",datetime.datetime.now().hour,":",datetime.datetime.now().minute,":",datetime.datetime.now().second,"]", " Stock encontrado: ("+nombre + " - " + tallas3[numero]+")")

    numero = numero+1

else:
    numero = numero+1
    if numero == len(tallas3):
        break

Then you could update this boolean value if you want to send another webhook but I will leave that to you.


Post a Comment for "Just Execute An IF Until The Value Is Changed Scraping"