-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathebaywebsitescraper.py
44 lines (26 loc) · 1009 Bytes
/
ebaywebsitescraper.py
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
from urllib.request import urlopen as uRep
from bs4 import BeautifulSoup as soup
my_url = 'https://www.ebay.com/b/Laptops-Netbooks/175672/bn_1648276'
uClient = uRep(my_url)
#opening file
page_html = uClient.read()
#close file
uClient.close()
#html parser
page_soup=soup(page_html,"html.parser")
#find specic class
containers = page_soup.findAll("div",{"class":"b-info"})
filename ="products.csv"
headers = "productname,productprice,pshipping\n"
f.write(" ")
for container in containers:
name = container.findAll("div",{"class":"b-info__title"})
productname = name[0].text.strip()
price = container.findAll("span",{"class":"b-info__trendprice"})
productprice = price[0].text.strip()
pshipping = container.findAll("div",{"class":"b-info__iteminfo"})
pshipping= pshipping[0].text.strip()
print("brand: "+productname)
print("price"+productprice)
print("pshipping"+pshipping)
f.write(productname.replace(",","|")+","+productprice.replace(",","|")+","+pshipping.replace(",","|"))