Last active
June 28, 2019 14:14
-
-
Save deepak2431/bd7857daeb50e1af9c6e87f7cc378864 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
from bs4 import BeautifulSoup as soup | |
s = requests.session() | |
URl = s.get('https://boodmo.com/catalog/3704-gaskets/m11290-maruti-swift_dzire/') | |
page_soup = soup(URl.text,"html5lib") | |
containers = page_soup.find_all("div",{"class":"products_block"}) | |
filename = "spare_parts.ods" | |
f = open(filename,"w") | |
headers = "Car Name, Spare parts, Cost\n" | |
prices_list = [] | |
products_list = [] | |
for link in containers: | |
p = link.find_all('a') | |
for h in p: | |
products, price = h.get('data-boodmo-products'), h.get('data-boodmo-price') | |
products_list.append(products) | |
prices_list.append(price) | |
product_names = [] | |
for p in range(0,len(products_list)): | |
p_str = products_list[p] | |
d = json.loads(p_str) | |
p_name = d["name"] | |
product_names.append(p_name) | |
for i in range (0,len(product_names)): | |
pr_n = product_names[i] | |
pr = prices_list[i] | |
f.write("Swift Dzire" + "," + pr_n.replace(",","|") + "," + pr + "\n") | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment