Simple Python Code to start the Web Scrapping

0
4
views

First here import the three libraries
1) BeautifulSoup as bs4
2) Request
3) Pandas

import bs4
import requests
import pandas as pd


res = requests.get('https://www.amazon.in/True-Elements-Gluten-Free-Rolled/product-reviews/B01LN5RJD6/ref=cm_cr_dp_d_show_all_btm?ie=UTF8&reviewerType=all_reviews')

type(res)

soup = bs4.BeautifulSoup(res.text,'lxml')

type(soup)

soup.select('.review-title')

for i in soup.select('.review-title'):
    print(i.text)

soup.select('.a-icon-alt')

for j in soup.select('.a-icon-alt'):
    print(j)
    

d = {'Title': [i],'Rating': [j]}   

df = pd.DataFrame(d, columns = ['Title','Rating'])

df

df.to_csv(r'E:\\Python\\MyFile.csv')   

LEAVE A REPLY

Please enter your comment!
Please enter your name here