Repository navigation
Expand file tree
/
Copy pathjabong.py
More file actions
52 lines (43 loc) · 1.6 KB
/
Copy pathjabong.py
File metadata and controls
52 lines (43 loc) · 1.6 KB
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
import sys
import requests
import urllib2
import itertools
from bs4 import BeautifulSoup
import re
count = 0
for index in range(1,12):
# url = "http://www.jabong.com/shoes/Adidas--adidas-originals--Nike--Puma--Red_Chief--Red_Tape--top-shop--Van_Heusen--vans--Woodland/?tt=shoes&rank=1&qc=shoes&page=1&limit=200"
url = "http://www.jabong.com/find/sony/?q=sons&tt=&rank=0&qc=sony"
r = requests.get(url)
soup = BeautifulSoup(r.content, "html.parser")
g_data = soup.find_all("section",{"class":"row search-product animate-products"})[0]
total_products = int(soup.find_all("p",{"class":"filter-prod-count"})[0].text.replace("PRODUCTS",""))
for items in g_data:
try:
img_url = items.contents[0].find_all("img")[0].get("src")
except:
pass
try:
name = items.contents[0].find_all("div",{"class":"h4"})[0].text
except:
pass
try:
price = items.contents[0].find_all("span",{"class":"standard-price"})[0].text
except:
pass
try:
sizes = items.contents[0].find_all("div",{"class":"avail-size"})[0]
avail_sizes =[]
for s in sizes:
if(s.text!="Sizes"):
avail_sizes.append(int(s.text))
except:
pass
print("Image_url = " +img_url)
print("Product Name : " +name)
print("Price(INR) : " +price)
print("Available Sizes : " +str(avail_sizes))
print("\n")
count=count+1;
if(count==total_products):
break;