Just some quick dummy questions, I just started learning BeautifulSoup and saw that there are different approaches for doing same thing and all approaches work fine..
I am curious to know the difference between them:
First: I tested the following three lines of code that has same functionality and they run successfully with same result. Question is what is the difference?
shipping_price = container.find('li', {'class':'price-ship'}).text.strip()
shipping_price = container.find('li', 'price-ship').text.strip()
shipping_price = container.find('li', class_='price-ship').text.strip()
Is there anything like one of those above three lines of code was from previous versions and will soon lose support and will be deprecated? does any of above codes offer extra functionality? or they are simply identical.
Second: this is a little different and it isn't about BeautifulSoup:
uClient = urlopen(my_url)
page_html = uClient.read()
uClient.close()
instead:
page_html = requests.get(my_url).text
I see that if I replace the later with former. There is no difference between the result. Therefore, what is the difference? is it only that in above two code they are using different module to grab my_url
? or there are other difference as well?
Please throw some light on these, thank you in advance.