Web Scraping in Python Code below:-
Full Explanation Here:-
Code Explanation Here:-
Full Explanation Here:-
Web Scraper using Python Tutorial in HINDI | Beautiful Soup
Code:-
import requests
import csv
from bs4 import BeautifulSoup as bs
def extractor():
page= requests.get("https://www.flipkart.com/search?q=nike+basketball+shoes&sid=osp%2Ccil%2C1cu&as=on&as-show=on&otracker=AS_QueryStore_OrganicAutoSuggest_1_16_sc_na_pr&otracker1=AS_QueryStore_OrganicAutoSuggest_1_16_sc_na_pr&as-pos=1&as-type=RECENT&suggestionId=nike+basketball+shoes&requestId=9d49338c-871c-4185-927b-c36615dd2e1f&as-searchtext=nike%20basketball%20")
soup=bs(page.content,'html.parser')
#print(soup)
#boxes=soup.find_all('div',attrs={"class":"bhgxx2 col-12-12"})
#print(len(boxes))
#box1=boxes[0].find_all('div',attrs={"class":"_3O0U0u"})
items = soup.find_all("div", attrs={"style":"width:25%"})
head="Product Name, Cost\n"
with open("data.csv","w") as f:
f.write(head)
f.close()
for item in items:
make_wrapper = item.findChild("div", class_="_2LFGJH")
make = make_wrapper.findChild("a", class_="_2mylT6")
price_wrapper = make_wrapper.findChild("a", class_="_2W-UZw")
price_wrapper_2 = price_wrapper.findChild("div", class_="_1uv9Cb")
price_wrapper_3 = price_wrapper_2.findChild("div", class_="_1vC4OE")
price = price_wrapper_3.text
with open("data.csv", "a",encoding='UTF-8') as f:
f.write(make.text+","+price.replace(',','')[1:]+"\n")
f.close()
extractor()
Great Article
ReplyDeleteFinal Year Projects in Python
Python Training in Chennai
FInal Year Project Centers in Chennai
Python Training in Chennai
I read that Post and got it fine and informative. email hunter extractor
ReplyDeleteIt is an excellent blog, I have ever seen. I found all the material on this blog utmost unique and well written. And, I have decided to visit it again and again. free bulk email sender software
ReplyDelete