-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdailyBestSellersLush.py
102 lines (80 loc) · 2.84 KB
/
dailyBestSellersLush.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 8 09:56:52 2021
@author: crystalhansen
"""
import bs4 as bs #beautifulSoup
import urllib.request
from datetime import datetime, timedelta
dt = datetime.now() #+ timedelta(hours=1) #sadds an hour for a condition of time is less than one hour ahead
d = dt.strftime("%m-%d-%Y_%H-%M-%S")
print('dailyBestSellers')
lushUrl="https://www.lush.ca/en/face/face/"
response= requests.get(lushUrl)
lushSoup = BeautifulSoup(response.text,'lxml')
fileName = "lush/face/products/daily_bestSellers_"+ d +".txt"
f=open(fileName,"w")
for product in lushSoup.find_all( 'div', class_="product"):
#print(product.text.strip())
f.write(product.text.strip() + "\n")
for href in product.find_all('a', class_="link",href=True):
#print(href['href'])
link = href['href']
f.write(link +"\n")
f.close()
lushUrl="https://www.lush.ca/en/hair/hair/"
#has best sellers
#section-swiper
#swiper-container
#swiper-wrapper
#product-tiles swiper-slide swiper
#product
# this has all the individual top level information get the link to get the ingredients
response= requests.get(lushUrl)
lushSoup = BeautifulSoup(response.text,'lxml')
fileName = "lush/hair/products/daily_hair_bestSellers_"+ d +".txt"
f=open(fileName,"w")
for product in lushSoup.find_all( 'div', class_="product"):
#print(product.text.strip())
f.write(product.text.strip() + "\n")
for href in product.find_all('a', class_="link",href=True):
#print(href['href'])
link = href['href']
f.write(link +"\n")
f.close()
lushUrl="https://www.lush.ca/en/body/body/"
#has best sellers
#section-swiper
#swiper-container
#swiper-wrapper
#product-tiles swiper-slide swiper
#product
# this has all the individual top level information get the link to get the ingredients
response= requests.get(lushUrl)
lushSoup = BeautifulSoup(response.text,'lxml')
fileName = "lush/body/products/daily_body_bestSellers_"+ d +".txt"
f=open(fileName,"w")
for product in lushSoup.find_all( 'div', class_="product"):
#print(product.text.strip())
f.write(product.text.strip() + "\n")
for href in product.find_all('a', class_="link",href=True):
#print(href['href'])
link = href['href']
f.write(link +"\n")
f.close()
lushUrl="https://www.lush.ca/en/discover/bestsellers/?cgid=bestsellers&start=0&sz=42"
#all best sellers
#list of items
response= requests.get(lushUrl)
lushSoup = BeautifulSoup(response.text,'lxml')
fileName = "lush/allBestSellers/daily_allBestSellers_"+ d +".txt"
f=open(fileName,"w")
for product in lushSoup.find_all( 'div', class_="product"):
#print(product.text.strip())
f.write(product.text.strip() + "\n")
for href in product.find_all('a', class_="link",href=True):
#print(href['href'])
link = href['href']
f.write(link +"\n")
f.close()