Whats the best way to improve this web scraper? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Whats the best way to improve this web scraper?

Hello all, I am a beginner Python developer, started not long ago. I was trying out web scraping with the BeautifulSoup library. The script I wrote at https://code.sololearn.com/cDP5W1cOFnTL/#py is meant to get the latest news items from a school website. Please let me know what you think and how it can/should be done better. Thanks in advance!

15th Aug 2019, 1:32 PM
hartechworld
hartechworld - avatar
2 Answers
+ 2
Line 6 is redundant, as well as line 8. You don't create a list without assigning a name to it. Also, you didn't even use lines 6-8 elsewhere in your code, then why bother to put them there? For line 9, why the pair of brackets? https://code.sololearn.com/cAX9m7rt5ocX/#py Do your selection by `soup.select(css_selector)`. Don't use `list()` indiscriminately.
16th Aug 2019, 8:11 PM
Gloria Borger
Gloria Borger - avatar
0
Thanks Gloria Borger for your feedback
24th Aug 2019, 4:39 PM
hartechworld
hartechworld - avatar