PolyEdge / scratchapi

[CURRENTLY UNMAINTAINED] Scratch API Interface
40 stars 15 forks source link

Getting message HTML fails #21

Closed micahlt closed 5 years ago

micahlt commented 5 years ago

I'm using scratchapi in a virtual environment (repl.it) and using it to generate my message page HTML using the command print(scratchapi.ScratchUserSession.messages.get_message_html()). Oddly, this generates the response <Response [200]> which sounds like an HTML error. I checked out some old issues, and #15 @PolyEdge stated that an HTML parser would be needed to view that kind of data. I attempted to install the html package, but that doesn't solve anything. Help?

PolyEdge commented 5 years ago
  1. the object you're seeing is a requests response object, the html will be stored in scratchapi.ScratchUserSession.messages.get_message_html().text
  2. i personally use beautifulsoup to parse html, with the lxml parser pip install beautifulsoup4 and pip install lxml then from bs4 import BeautifulSoup and parser = BeautifulSoup(etcetc..get_message_html(), "lxml")
micahlt commented 5 years ago

Wow, this project is still active! ;-) All right, I didn't know that the text would need to be specified. Thanks for the help!