Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BabyComeBack
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PLN
BabyComeBack
Commits
37f23585
Unverified
Commit
37f23585
authored
Sep 23, 2020
by
PLN (Algolia)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: handle 'temporarily sold out'
parent
2e036746
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
baby.py
baby.py
+10
-1
No files found.
baby.py
View file @
37f23585
...
...
@@ -3,6 +3,15 @@
import
requests
from
bs4
import
BeautifulSoup
blacklist
=
[
"Out of stock"
,
"temporarily sold out"
]
def
in_stock
(
stock
:
str
):
return
not
any
([
b
in
stock
for
b
in
blacklist
])
def
main
():
url
=
"https://onlinebabyplants.com/shop/exclusive-alocasia-zebrina-variegated/"
...
...
@@ -13,7 +22,7 @@ def main():
price
=
soup
.
find
(
attrs
=
{
"class"
:
"woocommerce-Price-amount amount"
})
.
text
stock
=
soup
.
find
(
attrs
=
{
"class"
:
"stock"
})
.
text
if
"Out of stock"
not
in
stock
:
if
in_stock
(
stock
)
:
sms
(
"
%
s en stock pour
%
s:
\"
%
s
\"\n
->
%
s"
%
(
name
,
price
,
stock
,
url
))
else
:
print
(
"
%
s pas en stock..."
%
name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment