0

Hey guys basically I have a website than I am an admin for, but do not have access to the source. We have an manual ban list for people who grief in our game. The site is hosted and ends in .php.

There is one dude who always puts iQ55 in his name who ruins matches and creates many many new accounts to get around the ban.

There is a page which does not require a login that shows who is currently in the games that is updated in real time.

My plan was to webscape that page and find any string containing the letters "IQ55" and add that name to the banlist. To do this I must log in to my admin account and to do this with my current knowledge it doesnt work with any site ending in .php.

My script I am using works with logging into github and my university portal so I know it works just not for .php as I cannot view the source.

from bs4 import BeautifulSoup
import mechanicalsoup


user2 = "XXXXXXXX"
pass2 = "XXXXXXXX"
browser = mechanicalsoup.Browser(soup_config={'features': 'lxml'})

# request github login page. the result is a requests.Response object
# http://docs.python-requests.org/en/latest/user/quickstart/#response-content
login_page = browser.get("https://XXXXXXXX.eu/bancp/bancp.php")

# similar to assert login_page.ok but with full status code in case of
# failure.
login_page.raise_for_status()

# login_page.soup is a BeautifulSoup object
# http://www.crummy.com/software/BeautifulSoup/bs4/doc/#beautifulsoup
# we grab the login form
login_form = mechanicalsoup.Form(login_page.soup.select_one('#login'))

# specify username and password
login_form.input({"username": user2, "password": pass2})

# submit form
page2 = browser.submit(login_form, login_page.url)

print(page2.soup.get_text())

I am using the Mechanical Soup module along with BeautifulSoup.

If this cannot be done can I get some pointers on where to go from here.

Broken down

*get all words containing "xxxx" from one page

*add all words to banlist on page that requires login and ends in .php

EDIT: it appear ending in PHP isnt the issue its just getting past this page using python. https://i.stack.imgur.com/PBM8o.jpg

Rick1990
  • 95
  • 12
  • 1
    What does the fact that the page ends in PHP have to do with anything? – Daniel Roseman May 05 '17 at 14:08
  • you dont want to just retrieve current users from user db? or better still add validation gateway for new user to ban all users with IQ55 in their name – A H Bensiali May 05 '17 at 14:09
  • What @DanielRoseman says. PHP is nothing but a pre-processor, meaning the browser just gets an HTML page, and your client should not be different to any other HTML page. – Jeff Huijsmans May 05 '17 at 14:09
  • http://stackoverflow.com/questions/2910221/how-can-i-login-to-a-website-with-python maybe this will be helpful for your issue – return May 05 '17 at 14:11
  • you guys are right. On further exploration if I manually log into the webpage in a browser the next page lets me view the source. The problem is getting past this page which doesnt let me view the source. http://imgur.com/a/KD5z5 – Rick1990 May 05 '17 at 14:17
  • That form uses Javascript. From Mechanical Soup documentation: A Python library for automating interaction with websites. MechanicalSoup automatically stores and sends cookies, follows redirects, and can follow links and submit forms. *It doesn't do Javascript.* (emphasis mine) – Josep Valls May 05 '17 at 15:47

0 Answers0