URL: Gaiaonline Python Login Tutorial
Was bored earlier, so just recorded it. I don't think many people will get much out of it, so be it. Final code is in the spoiler tags.
edit: should probably be said it was for Python 2.7.
Spoiler:PHP Code:
import urllib, urllib2, cookielib
import re
class HTTP:
def __init__(self):
self.cookiejar = cookielib.CookieJar()
self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookiejar))
def request(self, url, data = []):
return self.opener.open(url, urllib.urlencode(data)).read()
def setHeader(self, name, val):
self.opener.addheaders = [(name, value)]
class GaiaOnline:
def __init__(self):
self.HTTP = HTTP()
def login(self, username, password):
source = self.HTTP.request("http://www.gaiaonline.com/")
inputPattern = re.compile("<input([^>]+)>")
inputs = inputPattern.findall(source)
fieldPattern = re.compile("([a-zA-Z0-9\-\_]+)\=\"([^\"]{0,})\"")
fieldList = {}
for y in range(0, len(inputs)):
fields = fieldPattern.findall(inputs[y])
name = ""
val = ""
for z in range(0, len(fields)):
if fields[z][0] == "name":
name = fields[z][1]
elif fields[z][0] == "value":
val = fields[z][1]
try:
fieldList[name] = val
except:
pass
fieldList["username"] = username
fieldList["password"] = password
login = self.HTTP.request("http://www.gaiaonline.com/auth/login/", fieldList)
return login.find("Welcome back") != -1
def bump(self, topicId, text = "bump"):
topic = self.HTTP.request("http://www.gaiaonline.com/forum/fullmetal-alchemist/test/t." + str(topicId) + "/")
print topic
gaiaonline = GaiaOnline()
if gaiaonline.login("username", "password"):
gaiaonline.bump(81911787)
Results 1 to 20 of 20
- 24 Aug. 2012 07:12am #1
Python - Create a Gaia Online Login
- 24 Aug. 2012 03:08pm #2
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 291.00
I've been thinking of starting to try to do some Gaia stuff in Python, and this is a great starting place for me. Thanks for the tutorial!
- 24 Aug. 2012 05:49pm #3
Good work, Artificial. Will prove to be useful for those wanting to creating bots for Gaia in Python.
Also, lol Mac.
- 24 Aug. 2012 10:42pm #4
- 24 Aug. 2012 11:00pm #5
- 24 Aug. 2012 11:03pm #6
Windows is rubbish outside of gaming. I haven't used it in years.
Mac is great. The only potential issue I can see is the price, but when you have a job and aren't counting your pennies, it's a nonissue.
- 24 Aug. 2012 11:11pm #7
Unfortunately, right now I'm stuck with Windows. Gaming is a pretty neat perk though. And I think the price for Mac is a little outrageous even if you have a job. But there aren't too many complaints I have for Mac since I've never really used it more than briefly.
- 24 Aug. 2012 11:48pm #8
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 291.00
- 25 Aug. 2012 12:00am #9
You can say that about anything. Mac just cops a lot of criticism from the gaming community, because (speaking generally of course), they're mostly highschool/college students with no money who can't afford them. There is a bit of resentment there :p Anyways, why buy nice cars? Expensive food? It comes down to taste and preference. I prefer a Unix system, but don't like using Ubuntu/Debian recreationally all the time. Mac is like the perfect blend of the two different ends of the scale. And, with the amount of time I spend on the computer, the slightly higher cost really doesn't bother me at all.
Wine is pretty good, but for my Mac I rarely ever use software that is only available on Windows (the main exclusion being cross browser testing with Internet Explorer). Either way, I have Windows 8 dual booted on my work PC, and have a virtual instance of it on my Mac, so it's not a problem.
- 25 Aug. 2012 02:44am #10
Lol. Windows programs aren't really a necessity. There's probably a *nix alternative to about almost any piece of native Windows software.
Also VirtualBox/VMWare.
@Artficial: I meant that mainly in the sense that they're too high even if you have a job when it isn't really worth it. It's just glossy hardware on top of a proprietary, locked down version of Linux. Also, Win8? Why not just Win7? It's more mature and stable. And I'm hearing a lot of complaints about Windows 8 as of lately.Last edited by The Unintelligible; 25 Aug. 2012 at 02:47am.
- 25 Aug. 2012 03:07am #11
- 25 Aug. 2012 03:25am #12
Perhaps you should start caring brah
http://news.yahoo.com/blogs/technolo...164331963.html
I literally just now found this while browsing around a news feed. Wasn't searching for it either.
- 25 Aug. 2012 03:26am #13
That looks alien. I either have a very early RC, or Win 7.
- 25 Aug. 2012 03:05pm #14
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 875.00
What do you mean? That's what windows 8 looks like o-o at least, that's what the Developer preview looked like (I torrented and dual-booted it)
Also, I'm saying emulating windows for all of the small programs that people make. I use tons of programs that single people make, not large development studios. Most of the programs are windows-native and not cross-platform at all, which is one reason I use windows over a *nix system.
- 25 Aug. 2012 06:57pm #15
Then use a native Unix alternative if you can't find anything cross platform. And the authors of those "single programs" you're referring to are probably bad programmers if they can't make cross platform or otherwise non-native builds of the software in question.
VMs under the right circumstances could also prove to be as convenient as Wine is since VMs are actual emulation and Wine isn't (it's a compatibility layer - Wine is a recursive acronym that stands for Wine Is Not An Emulator).
- 26 Aug. 2012 05:24am #16
Moderator Bachelor of Science in Virginity
- Age
- 31
- Join Date
- Nov. 2009
- Location
- Toronto
- Posts
- 5,421
- Reputation
- 546
- LCash (Rank 3)
- 1.96
Nice tutorial, I've always thought about picking up Python but I barely program anymore. Also I was surprised when it worked without the "chap" code, I don't know if it's because I use the "/auth/login/" page or not but I need the chap :/.
Off-topic: I'll be sticking to Windows 7 for quite some time.
- 26 Aug. 2012 05:51am #17
- 26 Aug. 2012 05:58am #18
It disregards the chap field, because that's calculated with JS dynamically on the form's onsubmit event. Either way, a figure of the percentage of people with JS disabled varies quite a lot, but if you consider a relative conservative figure of 1.5%, if they required that chap field to be mandatory, they'd essentially be disallowing access to the site to 1.5% of their entire audience, which for them would be quite a large number. They simply throw it in there as another layer of protection for users with JS enabled.
- 26 Aug. 2012 06:16am #19
Interesting. I guess that's why the procedure for the challenge response handshake (and by that I mean more specifically the key. I know the handshake is done internally under the hood by the server) is in the JS of the web page. Never figured. Never honestly been much of a web dev person.
Do you find any appeal to it? If so, what? In comparison, which do you prefer: programming/software engineering/desktop application programming or web design/development.
Sorry for the little survey, lol.Last edited by The Unintelligible; 26 Aug. 2012 at 06:22am.
- 26 Aug. 2012 06:38am #20
Web Development is..okay. I hope I don't come across as being arrogant, but there's not a lot of room for me to progress any further in it (short of picking up new web frameworks like RoR/Django, which I'm not interested in). The frontend side of it (CSS/HTML/JS) is dead boring, because there's not a lot of mental stimulation (i.e. there's no real logic/problem solving required), whereas the backend work (PHP/Python), which originally interested me has now also just become repetitive. Also, as far as career advancements go, I think a senior PHP engineer in Australia can hope for (at best) low six figures (which by no means is a figure ' to roll your nose up at), but I'm in my early twenties, and when I was working full time I was almost at that point, so there's not much higher I could go. Not only that, but I recently went to a conference for work, and I realised that I'd vastly overestimated the skills of a lot of those sort of guys. Ive always progressed by setting myself a benchmark (i.e. a standard set by a certain group of people I want to emulate), and try to improve my skills to get to that benchmark. It was a bit disenchanting to see the skill levels of a lot of these guys (I'm sure it's different at the top IT companies like Microsoft and Google, but I wouldn't have a clue how to get a job there). Skillwise, I think I've got most of what I can from web development. I actually work from home now, and am basically allowed to pick and choose projects at work that interest me, but I've been gradually working less and less. tl;dr, over it, lol.
As for your second question, I find it hard now to just sit down and work on something that I don't find challenging. So, I hate programming simple desktop applications, websites, pieces of software, etc. Most of my programming time nowadays is spent taking part in programming competitions, which primarily just test your problem solving skills. I also declared Data Mining/Analytics as my major, which is a bit more math oriented, so I'm hoping that'll prove to be fun. If I don't have any objections to it, I'd like to pursue that field post Uni.Last edited by Artificial; 26 Aug. 2012 at 06:41am.