def checkItemDirect(self):
#NOTE: this function will most likely hamper performance but in some cases may improve it, leave it up to user choice to run this before checkout
#Basic Steps:
#Use BS to parse for <ul class="size options"
#Size marked as follows: <li class="8 available" data-option-title="8"
#Therefore, match data-option-title with user_size, then check the class for available keyword
session_get = self.user_session.get(self.URL_product)
print 'Status of requests.get: ' + str(session_get.status_code)
soup = BeautifulSoup(session_get.content, "lxml")
#Check that the lxml parser works for html
#Look to use SoupStrainer to improve parsing efficiency
for li in soup.select('li[data-option-title]'):
#print li['class']
#print type(li['class'])
if (self.user_size in li['class']) & ('available' in li['class']):
print 'Size ' + self.user_size + ' Available'
评论列表
文章目录