May-24-2018, 07:09 PM
I'm coding a page monitor to grab the link of new items on nike.com, but I'm not sure how to have python only return the link if the item is brand new (having just been uploaded to the site). What I have coded currently prints the link of the most recent item, but that link has been on the page for days. Again, I just want Python to return the link of a new item, not an item that has been on the site for days, weeks, etc. Any help would be great. Here is the code for my page monitor so far...
import requests from bs4 import BeautifulSoup import time import json headers = { 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36' } while True: def item_finder(): source = requests.get('https://www.nike.com/launch/', headers=headers).text soup = BeautifulSoup(source, 'lxml') card = soup.find('figure', class_='item ncss-col-sm-12 ncss-col-md-6 ncss-col-lg-4 va-sm-t pb2-sm pb4-md prl0-sm prl2-md ') card_data = "https://nike.com" + card.a.get('href') print(card_data)