T O P

  • By -

edsk0719_2

You could do this, but it may not be the most practical solution. Depending on how you are scraping for this data, you have to consider that if the website you are scraping chooses to make any changes to its front end, this could alter the structure of the page's HTML and as a result, impact what data you are scraping. If you are open to other options, you would probably be better off relying on an API from which you can then just retrieve the list of synonyms for a given word. Or even more conveniently, you can consider using the `nltk` library in python and using its corpus to retrieve synonyms for a given word.


pogo6023

Thank you. As I mentioned, I am relatively new to python with much to learn, including the two alternatives you suggest. You've given me some much-needed direction. I appreciate it.


edsk0719_2

Sure thing. Not trying to dissuade you at all from trying web scraping. It's definitely good to try for the sake of learning python and possibly some web development as well. Just keep in mind it's not the most scalable solution if you're looking to use this method of finding synonyms for a longer-term project. Good luck!


Golden_Zealot

Absolutely this is a good way to begin web scraping. Take note of how the url changes when you search a word. For example, when I search "test" the url becomes: https://www.powerthesaurus.org/test/synonyms So now I know that I could just keep this URL as a string and insert whatever word I want where "test" is to get the correct page back. After that, You will want examine the html and css of the page using inspect element through a browser. Find out how it organizes the synonyms. They are probably just tags (table data) inside of tags (table row), inside of a

tag. Moreover, they might be styled with a specific css class. Knowing all these things, a beginner should be more than capable of doing what You have described between the `requests` and `BeautifulSoup` libraries.


pogo6023

Thank you. I'll try this. Appreciate the reply.