Mangadex
I use mangadex pretty much daily to read manga and stuff, and recently I found out that I constantly go on it every now and then to check if there was an update on anything I read. So I decided to write a script that goes and checks my following list and gives me a notification when there is an update. It didn't work out. Using the requests module again, I tried just doing it off the bat, which didn't work because it required me to log in first of all. I thought that I'll just log in and that'll be that. How foolish I was.
So, usually, if you want to log in, you send a post request to the login page of said website, which contains the username and password of the account you want to log in as. You do this by creating a session, which will retain the cookies used for logging in, which I wanted so that I can refresh the page every few minutes without logging in again. So you go to the website and find the <input> tag's names and put them in a dictionary like so: {'login_username': 'helicofauna'}, and the same thing with the password. You send it, you get logged in, then the rest is easy.
I referenced multiple websites and stacksoverflow posts, and most say that works. Mine didn't work for some reason. I have no idea why. I tried things like sending the dictionary in json format and that didn't help. I first thought that it was because I didn't get a redirection, but just a confirmation of login (200), because some other websites have the redirect response (302). But I don't think that was the problem. I think the website just does not let me log in, or just doesn't take the data I send them for some reason. When I try to access the page again, it just tells me I'm not logged in and that I need to log in.
I also thought that it might have to do with the two factor authentication thing it had, but it's empty when I log in manually so I don't that's the problem.
Comments
Post a Comment