I want to set up a Python script that tells me if a product is back in stock. currently it scrapes the url below and parses the relevant section of the website but i can't figure out how to take this output variable i have called stock and store it as another variable called stock_history and then run another line asking if stock is equal or not to stock_history
i'm also getting an EOL while scanning string literal error while trying to store html data in stock_history. Is there a better way to do this?
import requests
from datetime import datetime
from bs4 import BeautifulSoup
import csv
now = datetime.now()
#enter website address
url = requests.get('http://ift.tt/2gNyPXO')
soup = BeautifulSoup(url.content,'html')
stock = (soup.find("div", "buy-now-bar-con"))
stock_history = '<div class="buy-now-bar-con">
<a class="current" href="antminer_s9_asic_bitcoin_miner.htm?flag=overview">Overview</a>
<a href="antminer_s9_asic_bitcoin_miner.htm?flag=specifications">Specification</a>
<a href="antminer_s9_asic_bitcoin_miner.htm?flag=gallery">Gallery</a>
<a class="btn-buy-now" href="javascript:;" style="background:#a7a4a4; cursor:not-allowed;" target="_self" title="sold out!">Coming soon</a>
</div>'
print(stock)
if stock == stock_history
print("still not in stock")
Aucun commentaire:
Enregistrer un commentaire