Issue
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()
?
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')
Answered By - Kenly
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.