Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Wikipedia Bot

Reply
Thread Tools

Wikipedia Bot

 
 
Peter Marsh
Guest
Posts: n/a
 
      05-21-2007
I'm planning on writing a simple Wikipedia Bot, but I'm having a little
difficulty. The bot needs to be able to log in to Wikipedia, but I'm not
sure if this code is working. It returns the Main Page, which does
happen after you log in, but I'm not entirely sure if this means if I've
actually logged in or not. Here's what I've used (ripped from:
http://www.ruby-doc.org/stdlib/libdo...et/HTTP.html):


require 'net/http'
require 'uri'

res =
Net::HTTP.post_form(URI.parse('http://en.wikipedia.org/w/index.php?title=Special:Userlogin&returnto=Main_Pa ge'),{'wpName'=>'username_not_this_one',
'wpPassword'=>'password_not_this_one'})
puts res.body

My user & password were correct.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Dan Zwell
Guest
Posts: n/a
 
      05-21-2007
Peter Marsh wrote:
> I'm planning on writing a simple Wikipedia Bot, but I'm having a little
> difficulty. The bot needs to be able to log in to Wikipedia, but I'm not
> sure if this code is working. It returns the Main Page, which does
> happen after you log in, but I'm not entirely sure if this means if I've
> actually logged in or not. Here's what I've used (ripped from:
> http://www.ruby-doc.org/stdlib/libdo...et/HTTP.html):
>
>
> require 'net/http'
> require 'uri'
>
> res =
> Net::HTTP.post_form(URI.parse('http://en.wikipedia.org/w/index.php?title=Special:Userlogin&returnto=Main_Pa ge'),{'wpName'=>'username_not_this_one',
> 'wpPassword'=>'password_not_this_one'})
> puts res.body
>
> My user & password were correct.
>


On the main page, see the text where it says "Sign in / create account"?
Search the body for that text. It won't say that if the login was
successful.

Dan

 
Reply With Quote
 
 
 
 
Peter Marsh
Guest
Posts: n/a
 
      05-21-2007
Dan Zwell wrote:
> Peter Marsh wrote:
>>
>> res =
>> Net::HTTP.post_form(URI.parse('http://en.wikipedia.org/w/index.php?title=Special:Userlogin&returnto=Main_Pa ge'),{'wpName'=>'username_not_this_one',
>> 'wpPassword'=>'password_not_this_one'})
>> puts res.body
>>
>> My user & password were correct.
>>

>
> On the main page, see the text where it says "Sign in / create account"?
> Search the body for that text. It won't say that if the login was
> successful.
>
> Dan


That's the thing, I've tried that but I can't find 'sign in' 'sign out'
or the my username, which usually appears in the top right. Also, I've
tried looking at the pade via IE after I've run the code, and that says
I'm not signed in as well.

Any ideas?

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Marcin Raczkowski
Guest
Posts: n/a
 
      05-21-2007
On Monday 21 May 2007 20:52, Peter Marsh wrote:
> Dan Zwell wrote:
> > Peter Marsh wrote:
> >> res =
> >> Net::HTTP.post_form(URI.parse('http://en.wikipedia.org/w/index.php?title
> >>=Special:Userlogin&returnto=Main_Page'),{'wpName '=>'username_not_this_one
> >>', 'wpPassword'=>'password_not_this_one'})
> >> puts res.body
> >>
> >> My user & password were correct.

> >
> > On the main page, see the text where it says "Sign in / create account"?
> > Search the body for that text. It won't say that if the login was
> > successful.
> >
> > Dan

>
> That's the thing, I've tried that but I can't find 'sign in' 'sign out'
> or the my username, which usually appears in the top right. Also, I've
> tried looking at the pade via IE after I've run the code, and that says
> I'm not signed in as well.
>
> Any ideas?


I recomend using scrubyt - there was example how to log into site, and post
comment - i guess it can be easly changed to wiki - but don't spam please

--
Marcin Raczkowski
---
Friends teach what you should know
Enemies Teach what you have to know

 
Reply With Quote
 
Ryan Davis
Guest
Posts: n/a
 
      05-21-2007

On May 21, 2007, at 10:27 , Peter Marsh wrote:

> I'm planning on writing a simple Wikipedia Bot, but I'm having a
> little
> difficulty. The bot needs to be able to log in to Wikipedia, but
> I'm not
> sure if this code is working. It returns the Main Page, which does
> happen after you log in, but I'm not entirely sure if this means if
> I've
> actually logged in or not.


Guess I'm going to be the one to ask: why do you need a wikipedia bot?



 
Reply With Quote
 
Rick DeNatale
Guest
Posts: n/a
 
      05-22-2007
On 5/22/07, Christian Luginbuehl <(E-Mail Removed)> wrote:
> > That's the thing, I've tried that but I can't find 'sign in' 'sign out'
> > or the my username, which usually appears in the top right. Also, I've
> > tried looking at the pade via IE after I've run the code, and that says
> > I'm not signed in as well.
> >
> > Any ideas?

>
> Check if there is a cookie involved that stores your session. As far as
> I understand the HTTP protocol, it is possible that WP is sending you a
> redirect together with your session cookie, which it expects to be sent
> back when (automatically) trying to GET the MainPage.
>
> It is just an idea, I never looked at the login process of WP and
> neither fully understand how much of the cookie handling is done for you
> with the Net::HTTP module.


I'm pretty sure that mediawiki (the software behind wikipedia) does in
fact use a cookie for authorization. It's been a while since I looked
at the code.

The OP might want to have a look at the pywikipediabot framework and
see how they do it. This is the 'official' bot framework for
wikipedia. It's written in python as the name would indicate, but
python code isn't THAT hard to read. <G>

It would be cool if there were a ruby equivalent to pywikipedia.
--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

 
Reply With Quote
 
Peter Marsh
Guest
Posts: n/a
 
      05-22-2007
Ryan Davis wrote:
> On May 21, 2007, at 10:27 , Peter Marsh wrote:
>
>> I'm planning on writing a simple Wikipedia Bot, but I'm having a
>> little
>> difficulty. The bot needs to be able to log in to Wikipedia, but
>> I'm not
>> sure if this code is working. It returns the Main Page, which does
>> happen after you log in, but I'm not entirely sure if this means if
>> I've
>> actually logged in or not.

>
> Guess I'm going to be the one to ask: why do you need a wikipedia bot?


I don't need one at all personally, but there are loads of requests for
bots of all sorts from the community. I thought that it'd be a nice
project to start, and would actually be useful! I'm not upto no good

Pywikipedia looks pretty promising - since I'm learning Ruby I may as
well learn Python!

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Stephan Maka
Guest
Posts: n/a
 
      05-22-2007
--lEGEL1/lMxI0MVQ2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Rick DeNatale wrote:
> It would be cool if there were a ruby equivalent to pywikipedia.


We have written what you're looking for, but a year ago and we've not
taken care of it since then. But it should be still working with recent
MediaWikis.

Be aware that most documentation is in german but the code itself is
english.

Homepage:
https://wiki.c3d2.de/Ruby-MediaWiki

Automatic RDoc in a Wiki:
https://wiki.c3d2.de/Ruby-MediaWiki/Documentation

Repository:
svn://svn.c3d2.de/ruby-mediawiki/trunk

Source browser:
http://trac.c3d2.de/ruby-mediawiki/browser/trunk/


Stephan

--lEGEL1/lMxI0MVQ2
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGUxoQuKMfCHUX8x0RAluqAJ9mvpciR5DtdAzVvhXRtz NF7EsKRwCeKv7X
man0x/a9m0PNIy/Q9lacbaw=
=Iruc
-----END PGP SIGNATURE-----

--lEGEL1/lMxI0MVQ2--

 
Reply With Quote
 
Stephan Maka
Guest
Posts: n/a
 
      05-22-2007
--9Ek0hoCL9XbhcSqy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Stephan Maka wrote:
> Be aware that most documentation is in german but the code itself is
> english.


Err. Actually only the homepage is german, the RDoc is english.

--9Ek0hoCL9XbhcSqy
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGUxtBuKMfCHUX8x0RAumyAJ0Zkity/57Aa16G0n3BSNrOxLb2cQCfZQ0x
akLjo721Nvy8Yy4yxqGyWYA=
=Ex6E
-----END PGP SIGNATURE-----

--9Ek0hoCL9XbhcSqy--

 
Reply With Quote
 
Peter Marsh
Guest
Posts: n/a
 
      05-22-2007
Stephan Maka wrote:
> Stephan Maka wrote:
>> Be aware that most documentation is in german but the code itself is
>> english.

>
> Err. Actually only the homepage is german, the RDoc is english.


Excellent, I'll have a look!

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cobra & bot... AMP Case Modding 6 10-05-2005 06:25 AM
Open-Source Java Instant Messenger Bot Server Nobody Java 0 09-21-2005 01:45 AM
Newbie Another NoClassDefFoundError (bot not a .class call error !) Lilian BRUN Java 2 03-05-2005 11:55 AM
How can I tell if a visitor is a search engine bot? Scott Allen ASP .Net 4 01-14-2005 05:14 PM
Spy Bot and Gator Richard Jordan Computer Support 11 08-05-2003 12:48 AM



Advertisments