-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscraper.py
More file actions
31 lines (25 loc) · 1.04 KB
/
scraper.py
File metadata and controls
31 lines (25 loc) · 1.04 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
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: dell
#
# Created: 06-01-2020
# Copyright: (c) dell 2020
# Licence: <your licence>
#-------------------------------------------------------------------------------
def main():
pass
if __name__ == '__main__':
main()
import requests
from bs4 import BeautifulSoup
URL="https://www.amazon.in/Sony-MDR-1000X-Wireless-Cancellation-Headphones/dp/B0734VL3RG/ref=sr_1_3?keywords=sony+headphones&qid=1578320187&sr=8-3"
headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"}
page=requests.get(URL ,headers=headers)
soup=BeautifulSoup(page.content, 'html.parser')
title=soup.find(id="productTitle")
print(title.string.strip())
price=soup.find(id="priceblock_ourprice")
cprice=price.string.strip('<span class="a-size-medium a-color-price priceBlockBuyingPriceString" id="priceblock_ourprice">')
print(cprice)