r/learnpython • • Nov 27 '19

Black Friday hack with python

So I just finished my python script to monitor the price of my target gadget this holiday. It’s going to be heavily discounted soon but it will go to the fastest finger.

I’ve written a python script with BeautifulSoup. I’ve also set email and SMS alerts in the script 😂😂

Was just wondering if there’s any other person doing this for Black Friday and Fastest Finger deals.

Update: Long overdue but just thought I should add that I got the phone.

362 Upvotes

100 comments sorted by

View all comments

2

u/[deleted] Nov 27 '19

[removed] — view removed comment

15

u/[deleted] Nov 27 '19

They’re not the same. Beautiful soup is a parser, extracting data from html. Selenium automates a browser to perform actions.

3

u/[deleted] Nov 27 '19

[removed] — view removed comment

8

u/TheAmazingJames Nov 27 '19

Selenium is way way slower and memory heavy. Selenium should only be used if you need JavaScript to render/work.

2

u/Mathew_Berrys_Cock Nov 27 '19

Would more ram help this problem?

2

u/TheAmazingJames Nov 27 '19

Selenium’s usually using chromium in the background so it’s unlikely to max out your RAM unless you’re trying to run on a barebones setup, but it will be using significantly more than a requests/beautifulsoup setup and that could be costly if you’re running it in the cloud. The main reason not to though is speed. Typically I’d expect requests to run 5-10x faster than selenium. Selenium also requires more maintenance in terms of chromedriver updates and is harder to deploy on others’ systems. I’m not saying Selenium isn’t awesome, but it’s for specific use cases where you’re either browser testing or need JavaScript.

1

u/pulsarrex Nov 27 '19

Can you eli5 what a 'parser' is?

3

u/Conrad_noble Noble1988 Nov 27 '19

I think it means it translates html into user friendly readable text

1

u/OMGpancakeable Nov 27 '19

Not quite “translate”. Parsing: resolve (a sentence) into its component parts and describe their syntactic roles.

1

u/rrjamal Nov 27 '19

It splits data in a way you want. An HTML doc can be a shit ton of words. You'd parse it down to split and retrieve only the bits you care about

7

u/adriangc Nov 27 '19

I’m more curious to understand why people choose BS over Scrapy.

2

u/BruceJi 📦 Nov 27 '19

Isn't scrapy pretty new?

1

u/adriangc Nov 28 '19

Believe it came out in 2008.

1

u/solostman Nov 27 '19

It’s been around a bit. For awhile you could only run it in Python 2.

2

u/GrandRub Nov 27 '19

i am a python newbie and found scrapy yesterday and i ask myself the same question.. whats the pros and cons of scrapy?