makuto / Liked-Saved-Image-Downloader

Save content you enjoy!
https://macoy.me/code/macoy/Content-Collector
MIT License
89 stars 10 forks source link

A Few Questions From a Newbie #13

Closed svnibbal closed 6 years ago

svnibbal commented 6 years ago

Hello, I've been trying to muddle through this and I think I've gotten pretty far, but I would appreciate some help with a couple issues I've had.

1) I'm getting "TypeError: write() argument must be str, not bytes". From what I've googled it has to do with opening the file in binary or text in Python 3. Apparently I need to add the b flag to my output. Myquestion is, how do I go about adding that flag? I've been able to get the script to work with Python 2.7, but I'd like to know what I can do to fix it for 3+ for the future. Just in case, the full error is:

Traceback (most recent call last): File "redditUserImageScraper.py", line 248, in main() File "redditUserImageScraper.py", line 229, in main

2) My second problem is "UnicodeEncodeError: 'charmap' codec can't encode characters in position 38-41: character maps to " I think it has something to do with the imgur album title having a "-" in it. I think solving issue 1) will actually solve this issue since Python 3.6 now accepts all Unicode characters right? That said, if I say, wanted to change the "-" to a "?" how would I do that? The full error again for posterity:

Traceback (most recent call last): File "redditUserImageScraper.py", line 248, in main() File "redditUserImageScraper.py", line 236, in main only_important_messages = settings['Only_important_messages']) File "D:\Alpha\redditLikedSavedImageDownloader-master\imageSaver.py", line 465, in saveAllImages soft_retrieve_imgs = soft_retrieve_imgs) File "D:\Alpha\redditLikedSavedImageDownloader-master\imageSaver.py", line 249, in saveAllImgurAlbums

Thanks a lot for this project! Been putting off scrapping my likes/favorites for years and this is perfect. Plus it's been a fun day learning python.

makuto commented 6 years ago

Hey svnibbal, I'm glad you're using the script and learning Python!

Those errors are related to Python 3 not being supported yet. I looked into it for a couple hours one day and made some changes, but haven't yet figured out Python 3 string support. I wanted to modify the script such that it would work in 2 and 3 but am not sure if that is possible.

I'm going to take a look at it tonight and see if I can get Python 3 support wrapped up.

svnibbal commented 6 years ago

Thanks for the quick reply and I appreciate the help. Don't feel rushed to investigate it on my behalf though! I've waited a few years to do this and I'm fine waiting a bit longer. :)

makuto commented 6 years ago

f959e9b resolves this! It was more work than expected but it's done now. You should be able to switch to Python 3 without any differences now.