Am I Making Mistakes in My Web Scraping Python Code?

0
2
Asked By CuriousCoder92 On

Hey everyone! I'm just a beginner in programming and Python, and I've created a simple web scraping script. My script prompts the user for a hockey player's name, constructs a URL to scrape their stats from the hockey-reference website, and then prints out those stats. I'm worried that I'm doing things wrong or inefficiently. I'd love to get your feedback on my code and any suggestions for improvement! I learned everything from online guides and documentation, so if I'm missing something, that's my excuse. Thanks!

3 Answers

Answered By CodeWizardX On

You might want to take a look at the code duplication you've included; it seems like you've posted the same code twice. Also, using a prompt for input is cool, but consider looking into `sys.argv` or libraries like `argparse` to get input more efficiently. It could streamline the process instead of looping for player names directly!

CuriousCoder92 -

Haha, I didn't realize I posted it twice! I'll check out `sys.argv` as well; thanks for the tip!

Answered By TechieDev On

Your approach works, but instead of using a loop, have you considered pulling the player's name from the command line arguments? It might simplify things and reduce the need for unnecessary prompts.

CuriousCoder92 -

Oh, I've never used `sys.argv`! Sounds useful, I'll look into it. Thanks!

Answered By ScrappyNinja On

Your code actually works fine! Don't worry too much about feeling unsure; everyone starts somewhere. Just keep experimenting and learning from your mistakes. It seems functional to me! 91e3fc91e3fc

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.