Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Handmade Character Soft Toy Bluey Bingo
anil1961
Updated:
Monday at 3:55 PM
Colombo
Dahua POE Switch 8 Ports (DH-PFS3010-8ET-65)
hashaz2012
Updated:
Monday at 11:56 AM
Ad icon
Singapore V2Ray VPN for Tunneling
hu KANNA
Updated:
Friday at 10:01 AM
Dating Website & Online Chat Room
hotvideo
Updated:
Jul 30, 2026
DJI Mini 4 Pro Drone Combo Plus
Hawaka
Updated:
Jul 30, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
UoM Online Course 3 - Python Programming එක ඉවර කරපු අය...
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="pasindu201" data-source="post: 27636462" data-attributes="member: 565625"><p>from traceback import print_list</p><p>import requests</p><p>import json</p><p></p><p>import sys</p><p>sys.path.insert(0,'bs4.zip')</p><p>from bs4 import BeautifulSoup</p><p></p><p>#Imitate the Mozilla</p><p>user_agent = {'User-agent': 'Mozilla/5.0'}</p><p></p><p></p><p></p><p>def compare_prices(product_laughs,product_glomark):</p><p></p><p></p><p> # laugfs product</p><p> html_laugfs = requests.get(product_laughs).content</p><p> soup_laugfs = BeautifulSoup(html_laugfs, 'html.parser')</p><p></p><p> prod_laugfs = soup_laugfs.find('span',class_="regular-price")</p><p></p><p> prodName = soup_laugfs.find('div',class_="product-name")</p><p> product_name_laughs=prodName.get_text()</p><p></p><p> prod_laugfs = prod_laugfs.get_text() # Will get text from html tags</p><p> product_laugfs = prod_laugfs.strip() # Removing special characters like \n (newline)</p><p> #print(product_name_laughs)</p><p> prod_price_laugfs = product_laugfs[3:]</p><p> price_laughs = float(prod_price_laugfs)</p><p> #print(price_laughs)</p><p></p><p> # Glomark product</p><p></p><p> html_glomark = requests.get(product_glomark).content</p><p> soup_glomark = BeautifulSoup(html_glomark, 'html.parser')</p><p></p><p> prod_glomark = soup_glomark.find_all('script')[6].text</p><p> prod_glomark = json.loads(prod_glomark)</p><p></p><p> product_name_glomark = prod_glomark['description']</p><p> offers_glomark = prod_glomark['offers'][0]</p><p> price_glomark = float(offers_glomark['price'])</p><p> #print(product_name_glomark)</p><p> #print(price_glomark)</p><p></p><p> </p><p> print('Laughs ',product_name_laughs,'Rs.: ' , price_laughs)</p><p> print('Glomark ',product_name_glomark,'Rs.: ' , price_glomark)</p><p> </p><p> if(price_laughs>price_glomark):</p><p> print('Glomark is cheaper Rs.:',price_laughs - price_glomark)</p><p> elif(price_laughs<price_glomark):</p><p> print('Laughs is cheaper Rs.:',price_glomark - price_laughs) </p><p> else:</p><p> print('Price is the same')</p><hr /><p>me widihata wenas karanna one,hariyatama script eke number eka one,anika kalin oya manual function ekata call karala thibba ethakota deparak output eka print wenwa,ehema unama eyala dena test cases walata hariyanne na,mkada eyalage test case eke ekai oyage ekai dekak print wenwa</p><p>------ <span style="font-size: 10px">Post added on [DATETIME="UT"]1650914033[/DATETIME]</span></p></blockquote><p></p>
[QUOTE="pasindu201, post: 27636462, member: 565625"] from traceback import print_list import requests import json import sys sys.path.insert(0,'bs4.zip') from bs4 import BeautifulSoup #Imitate the Mozilla user_agent = {'User-agent': 'Mozilla/5.0'} def compare_prices(product_laughs,product_glomark): # laugfs product html_laugfs = requests.get(product_laughs).content soup_laugfs = BeautifulSoup(html_laugfs, 'html.parser') prod_laugfs = soup_laugfs.find('span',class_="regular-price") prodName = soup_laugfs.find('div',class_="product-name") product_name_laughs=prodName.get_text() prod_laugfs = prod_laugfs.get_text() # Will get text from html tags product_laugfs = prod_laugfs.strip() # Removing special characters like \n (newline) #print(product_name_laughs) prod_price_laugfs = product_laugfs[3:] price_laughs = float(prod_price_laugfs) #print(price_laughs) # Glomark product html_glomark = requests.get(product_glomark).content soup_glomark = BeautifulSoup(html_glomark, 'html.parser') prod_glomark = soup_glomark.find_all('script')[6].text prod_glomark = json.loads(prod_glomark) product_name_glomark = prod_glomark['description'] offers_glomark = prod_glomark['offers'][0] price_glomark = float(offers_glomark['price']) #print(product_name_glomark) #print(price_glomark) print('Laughs ',product_name_laughs,'Rs.: ' , price_laughs) print('Glomark ',product_name_glomark,'Rs.: ' , price_glomark) if(price_laughs>price_glomark): print('Glomark is cheaper Rs.:',price_laughs - price_glomark) elif(price_laughs<price_glomark): print('Laughs is cheaper Rs.:',price_glomark - price_laughs) else: print('Price is the same') [HR][/HR] me widihata wenas karanna one,hariyatama script eke number eka one,anika kalin oya manual function ekata call karala thibba ethakota deparak output eka print wenwa,ehema unama eyala dena test cases walata hariyanne na,mkada eyalage test case eke ekai oyage ekai dekak print wenwa ------ [SIZE=2]Post added on [DATETIME="UT"]1650914033[/DATETIME][/SIZE] [/QUOTE]
Insert quotes…
Verification
Haya warak paha keeyada? (haya wadi kireema paha)
Post reply
Top
Bottom