0

I'm trying to log into a website called Roblox with python. Right now what I have isn't working. When I run the code the output is:

[]
(True, 200)

above I am expecting the first line to say "Hello, awdfsrgsrgrsgsrgsg22!"

code:

import requests
from lxml import html

payload = {
    "username": "awdfsrgsrgrsgsrgsg22", 
    "password": "newyork2000", 
    "csrfmiddlewaretoken": "WYa7Qp4lu9N6"
}

session_requests = requests.session()

login_url = "https://www.roblox.com/Login"
result = session_requests.get(login_url)

tree = html.fromstring(result.text)

result = session_requests.post(
    login_url, 
    data = payload, 
    headers = dict(referer=login_url)
)

url = 'https://www.roblox.com/home'
result = session_requests.get(
    url, 
    headers = dict(referer = url)
)


tree = html.fromstring(result.content)
welcomeMessage = tree.xpath('//*[@id="HomeContainer"]/div[1]/div/h1/a')

print(welcomeMessage) #expecting "Hello, awdfsrgsrgrsgsrgsg22!"
print(result.ok, result.status_code)
  • 1
    I would assume that your problem is that your xpath expression is not right for the content you're getting back. Can you post the raw HTML you're getting back (result.content)? I can't think how anyone is going to be able to help you without that. - and since you're getting back a 200, I'm guessing that you may very well be logged in even though you aren't extracting the string you expect from the response. – CryptoFool Mar 17 '19 at 05:13
  • @Steve When I put in a wrong password, I still get 200. Also, I don't think it is the xpath because I copied it directly from inspect element. –  Mar 17 '19 at 06:36
  • 2
    I sniffed login traffic for this site, you need to do around 10 POSTs request with bunch of GETs to different address, to be logged in. There is captach to be handle as well. Use Burp Suite to see what browser send to the website for login process . check [screen-shot](https://imgur.com/a/id1Gm8R) of the captured traffic – HadiRj Mar 17 '19 at 06:56
  • @James, cool. I was just taking a stab given what I knew, and the fact that it might be hard for someone to reproduce your results with a particular site. I hope you figure this out soon! – CryptoFool Mar 17 '19 at 14:41

0 Answers0