P
P
progerstas2020-08-29 17:26:18
Python
progerstas, 2020-08-29 17:26:18

Why is it displaying a different page?

Why is the get_serfing function displaying a page for users who are not logged in?

import requests
from bs4 import BeautifulSoup


class Bot():

    def __init__ (self, username = 'user', password = 'password', user_agent = 'user_agent'):
        self.username = username # ник
        self.password = password # секрет 3:
        self.user_agent = user_agent # можно взять тут: https://developers.whatismybrowser.com/useragents/explore/operating_system_name/

    # вход в систему
    def login (self):
        data = {
            'username': self.username,
            'password': self.password,
            'func': 'login',
            'dopinfa': 'Mesa Intel(R) HD Graphics 610 (KBL GT1)',
            'dopinfaw': '1920x972'
        }

        url = 'https://profitcentr.com/ajax/log_reg.php'
        s = requests.Session()
        res = s.post(url, data = data)

        return res.status_code
    
    # узнать кол-во выполненных заданий серфинга
    def get_serfing (self):
        url = 'https://profitcentr.com/'
        headers = {
            'User-Agent': self.user_agent
        }

        res = requests.get(url, headers=headers)
        soup = BeautifulSoup(res.content, 'html.parser')
        print(soup)
        table = soup.findAll('table', class_ = 'referals')
        print(table)



a = Bot(username = 'секрет, password = 'секрет' user_agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36')
a.login()
a.get_serfing()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-08-29
@progerstas

Why should it return an authorized user page?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question