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
Ad icon
Jobreceive.com for sale
Blogerwiki
Updated:
Yesterday at 8:55 PM
Post Your Vehicle for Sale — FREE! - https://libro.lk
Kalu_Puth
Updated:
Yesterday at 7:38 PM
ඔයාගෙ Assignment හෝ Thesis එක හරියට හදාගමු
ErMurazor
Updated:
Saturday at 10:52 PM
Ad icon
BlackWall V2ray servers
hu KANNA
Updated:
Sep 23, 2026
Peppa Pig Family Plush Toy Set – 5 Characters
anil1961
Updated:
Sep 19, 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: 28289235" data-attributes="member: 565625"><p>[CODE=python]from traceback import print_list</p><p>import requests</p><p>import json</p><p>from bs4 import BeautifulSoup</p><p></p><p>#Imitate the Mozilla browser.</p><p>user_agent = {'User-agent': 'Mozilla/5.0'}</p><p></p><p></p><p>def compare_prices(product_laughs,product_glomark):</p><p></p><p> #Aquire the web pages which contain product Price</p><p> htmlLaughs = requests.get(product_laughs).content</p><p> htmlglow = requests.get(product_glomark,headers=user_agent).content</p><p> </p><p></p><p> soup = BeautifulSoup(htmlLaughs, 'html.parser')</p><p></p><p> </p><p> priceSpan = soup.find_all('span',attrs={'class':'price'})</p><p> productnameElement = soup.find_all('div',attrs={'class':'product-name'})</p><p></p><p> product_name_laughs=""</p><p> for item in productnameElement:</p><p> product_name_laughs = (item.find('h1').text)</p><p> </p><p></p><p> price_laughs=float(priceSpan[1].text[3:])</p><p> </p><p> product_name_glomark=""</p><p> price_glomark=0.0;</p><p></p><p> glowSoup = BeautifulSoup(htmlglow, 'html.parser')</p><p></p><p> </p><p> #inline script contains the informaation,check source code</p><p> findInlineScript= glowSoup.find_all('script')[6].text</p><p> jsonObjectfromScript = json.loads(findInlineScript)</p><p></p><p></p><p> </p><p> price_glomark = float(jsonObjectfromScript["offers"][0]["price"])</p><p></p><p> product_name_glomark = glowSoup.find_all('div',attrs={'class':'product-title'})</p><p></p><p> for item in product_name_glomark:</p><p> product_name_glomark = (item.find('h1').text)</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><p></p><p></p><p>if __name__ == "__main__":</p><p> compare_prices("https://www.laugfssuper.com/index.php/coconut-105320.html","https://glomark.lk/coconut/p/11624")[/CODE]</p></blockquote><p></p>
[QUOTE="pasindu201, post: 28289235, member: 565625"] [CODE=python]from traceback import print_list import requests import json from bs4 import BeautifulSoup #Imitate the Mozilla browser. user_agent = {'User-agent': 'Mozilla/5.0'} def compare_prices(product_laughs,product_glomark): #Aquire the web pages which contain product Price htmlLaughs = requests.get(product_laughs).content htmlglow = requests.get(product_glomark,headers=user_agent).content soup = BeautifulSoup(htmlLaughs, 'html.parser') priceSpan = soup.find_all('span',attrs={'class':'price'}) productnameElement = soup.find_all('div',attrs={'class':'product-name'}) product_name_laughs="" for item in productnameElement: product_name_laughs = (item.find('h1').text) price_laughs=float(priceSpan[1].text[3:]) product_name_glomark="" price_glomark=0.0; glowSoup = BeautifulSoup(htmlglow, 'html.parser') #inline script contains the informaation,check source code findInlineScript= glowSoup.find_all('script')[6].text jsonObjectfromScript = json.loads(findInlineScript) price_glomark = float(jsonObjectfromScript["offers"][0]["price"]) product_name_glomark = glowSoup.find_all('div',attrs={'class':'product-title'}) for item in product_name_glomark: product_name_glomark = (item.find('h1').text) 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') if __name__ == "__main__": compare_prices("https://www.laugfssuper.com/index.php/coconut-105320.html","https://glomark.lk/coconut/p/11624")[/CODE] [/QUOTE]
Insert quotes…
Verification
Haya warak paha keeyada? (haya wadi kireema paha)
Post reply
Top
Bottom