-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NSFW boards/threads which require cookies can't be loaded, and if provided python still throws an error #3
Comments
Every user has To get your Then replace headers = {
"Accept": "image/webp,*/*",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
"Cookie": "usercode_auth=MY-USER-CODE; wakabastyle=Futaba;"
} |
Argh, forgot to add it. I did found out thing about usercode_auth in dvach.py file. Replaced that but result is exactly same. When you open private browser session, you get 404 on GG and other pages. |
I can not catch this error. I tried every nsfw board, but it works for me. Try:
If it doesn't help, create new file in repository root directory and paste this code and replace import dvach
import time
board_name = 'TYPE BOARD NAME HERE'
board = dvach.Board.from_json(dvach.Board.json_download(board_name))
board.update_threads()
for key in list(board.threads.keys()):
thread = board.threads[key]
thread.update_posts()
print(f'Загружен тред: {thread.num}, постов: {len(thread.posts)}')
time.sleep(2) This script downloads threads one by one. It catches the error. If scripts throws exception let me know. |
@r3538987
And it worked. |
Assuming code you provided will extent cookie expiring date. But I doubt it will help.
Now will check piece of code you offered above. Does this mean that when asking certain boards I get empty JSON responses ? |
Yes. You got empty response for some reason. |
========== RESTART: C:\Users\user\Desktop\2ch-main\thread_saver.py ========== Okay, later I will try to debug this and see where issue is. |
to anyone wondering here with this problem, solved it via modifying the |
2 years later, don't think this is actual, at least for me. :) |
the point is not that i hardcoded it, the point is that i at least passed it to the method, othervise json was always empty (for boards that require this code), passing headers also didn't work (as in commented-out method call) so i googled how to pass cookies to requests.get and did just that |
Strange is that some boards like "gg" work, but others - in example "fet" - doesn't.
The text was updated successfully, but these errors were encountered: