Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot get quantity value from webpage source code

I’m trying to get product in-stock counts from a webpage; the example product is as follows:

Product link
I did a lot of scrapping projects, but this case is new because I should get the product in the stock count too. I tried to change the value(count) to search for it and find it in the source code. I didn’t find the numerical value, although. Is there any way to get the maximum of any product (this product, for example) with beautiful soup and requests.get()?
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The following code will try to get the value attribute of an input with quantity-num class:

r = requests.get('https://www.lightinthebox.com/en/p/wosawe-men-s-cycling-jacket-windbreaker-waterproof-rain-jacket-reflective-running-jackets-bike-hooded-packable-raincoat-top-lightweight-breathable_p8747531.html?category_id=799&prm=1.2.1.48')
 
soup = BeautifulSoup(r.content, 'html.parser')

s = soup.find('input', class_='quantity-num')

quantity = s.get('value')

Update:

To get the max quantity, look for the div with quantity-select class:

s = soup.find('div', class_='quantity-select')

max_quantity = s.get('data-max-quantity')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading