-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetwork_programs.py
More file actions
42 lines (29 loc) · 1.17 KB
/
Copy pathNetwork_programs.py
File metadata and controls
42 lines (29 loc) · 1.17 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
32
33
34
35
36
37
38
39
40
41
import urllib.request, urllib.parse, urllib.error
import ssl
from bs4 import BeautifulSoup
class Soupbot():
def findPrice(self):
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
url = 'https://www.amazon.com/dp/B0000Y7KNQ/ref=nav_timeline_asin?_encoding=UTF8&psc=1'
# Amazon Price Checker
html = urllib.request.urlopen(url,context=ctx).read()
soup = BeautifulSoup(html,'html.parser')
price = soup.find(id = 'priceblock_ourprice').text
return price
def findName(self):
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
url = 'https://www.amazon.com/dp/B0000Y7KNQ/ref=nav_timeline_asin?_encoding=UTF8&psc=1'
# Amazon Price Checker
html = urllib.request.urlopen(url,context=ctx).read()
soup = BeautifulSoup(html,'html.parser')
productTitle = soup.find(id = 'productTitle').text
return productTitle.strip()
# Debug
# title = Soupbot().findName()
# print (title)