how to make python make a post

This forum is for discussion about anything else.
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10559
Joined: April 28, 2011
Pronoun: he/they

how to make python make a post

Post Post #0 (ISO) » Mon Oct 17, 2016 9:49 am

Post by Psyche »

Hi,

Hopefully one of you computer nerd types knows how to do this.

I know how to make python log into mafiascum.net for me. My favored method is to use scrapy to request 'http://forum.mafiascum.net/ucp.php?mode=login' and then follow up in the parse function with return FormRequest.from_response(response, formdata={'username': 'psyche', 'password': 'supercoolpassword'}, callback=self.after_login)].

I feel like doing something similar with FormRequest can also make a post for me, but looking at the html for a typical reply page, I just don't see what to include in the formdata part of the above code. I am so dumb, so stupid, so beneath you. As my better, please have mercy, and tell me how to make this work.

PS: If you know a (python) method for logging into mafiascum and making posts that doesn't involve scrapy or its FormRequest, I'd probably be just fine knowing about that instead. Just help me. I'll be ur bubble box bitch??
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10559
Joined: April 28, 2011
Pronoun: he/they

Post Post #1 (ISO) » Mon Oct 17, 2016 5:18 pm

Post by Psyche »

updated problem description: http://stackoverflow.com/questions/4009 ... ormrequest

api for formrequest (ctrl+f formrequest!): https://doc.scrapy.org/en/latest/topics ... ponse.html
User avatar
Bicephalous Bob
Bicephalous Bob
Mafia Scum
User avatar
User avatar
Bicephalous Bob
Mafia Scum
Mafia Scum
Posts: 3828
Joined: June 4, 2013
Location: I don't know why you're linking me to pictures of babies on Facebook

Post Post #2 (ISO) » Tue Oct 18, 2016 10:50 pm

Post by Bicephalous Bob »

csrf protection
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10559
Joined: April 28, 2011
Pronoun: he/they

Post Post #3 (ISO) » Wed Oct 19, 2016 3:38 am

Post by Psyche »

its allll done
User avatar
inte
inte
Mafia Scum
User avatar
User avatar
inte
Mafia Scum
Mafia Scum
Posts: 3523
Joined: November 15, 2011
Location: C-bus

Post Post #4 (ISO) » Wed Oct 19, 2016 3:52 am

Post by inte »

post code
Show
W(eed)/L: 420/2

T:2/2/0
S:1/0/0
N:0/0/0

When dreamen gad-adto-ello-lahwer time-antime ageeee-ayeeeeah-ye-e-ah-nn.
User avatar
vonflare
vonflare
doot
User avatar
User avatar
vonflare
doot
doot
Posts: 3093
Joined: January 1, 2014
Location: Blue Gatorade Factory

Post Post #5 (ISO) » Wed Oct 19, 2016 4:53 pm

Post by vonflare »

now make a bot that posts to sitechat
THIS POST IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
User avatar
chamber
chamber
Cases are scummy
User avatar
User avatar
chamber
Cases are scummy
Cases are scummy
Posts: 10703
Joined: November 20, 2005

Post Post #6 (ISO) » Wed Oct 19, 2016 7:30 pm

Post by chamber »

bot posting to site chat would need to work completely differently.
Taking a break from the site.
User avatar
Claus
Claus
Mafia Scum
User avatar
User avatar
Claus
Mafia Scum
Mafia Scum
Posts: 1734
Joined: June 1, 2007
Location: Tsukuba
Contact:

Post Post #7 (ISO) » Wed Oct 19, 2016 7:53 pm

Post by Claus »

source code or it didn't happen.
http://www.youtube.com/watch?v=XVVmAG0RXmo
User avatar
Flubbernugget
Flubbernugget
Survivor
User avatar
User avatar
Flubbernugget
Survivor
Survivor
Posts: 11751
Joined: June 26, 2014

Post Post #8 (ISO) » Thu Oct 20, 2016 2:20 pm

Post by Flubbernugget »

Why can't you just cURL it?
User avatar
Bicephalous Bob
Bicephalous Bob
Mafia Scum
User avatar
User avatar
Bicephalous Bob
Mafia Scum
Mafia Scum
Posts: 3828
Joined: June 4, 2013
Location: I don't know why you're linking me to pictures of babies on Facebook

Post Post #9 (ISO) » Fri Oct 21, 2016 6:45 am

Post by Bicephalous Bob »

Psyche, in his top-rated SE answer, wrote:The other answers cite minor effects related to your phenomena, but there's something more pervasive going on.

In Carney et al's research report "Power Posing: Brief Nonverbal Displays Affect Neuroendocrine Levels and Risk Tolerance", it was found that "power posing" increases testosterone and cortisol levels which leads to, among other things, a greater tolerance of risk in general — which is practically the definition of confidence.
Replication crisis hit you too huh
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10559
Joined: April 28, 2011
Pronoun: he/they

Post Post #10 (ISO) » Fri Oct 21, 2016 8:34 am

Post by Psyche »

i was young
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10559
Joined: April 28, 2011
Pronoun: he/they

Post Post #11 (ISO) » Sat Oct 29, 2016 7:39 pm

Post by Psyche »

Code: Select all

class MakePostSpider(scrapy.Spider):
    name = 'MakePostSpider'
    start_urls = ['http://forum.mafiascum.net/ucp.php?mode=login']

    def parse(self, response):
        return [FormRequest.from_response(response,
                formdata={'username': 'psyche', 'password': 'coolpassword'},
                callback=self.after_login)]
    
    def after_login(self, response):
        # Request the reply page
        replyurl = 'http://forum.mafiascum.net/posting.php?mode=reply&f=10&t=61319'
        return Request(url=replyurl, callback=self.makepost)
    
    def makepost(self, response):
        # From there, do a form request, filling "message" with whatever
        # the callback should be to an empty function. Wonder if i can avoid those.
        return FormRequest.from_response(response,
            formdata={'icon': '0', 'addbbcode20': '100', 'message':'[img]http://i.giphy.com/xTiTnrQlrWi7wxK2re.gif[/img]',
                      'lastclick': '1476765260', 'post': 'Submit','creation_time': '1476765260',
                      'form_token': 'ddd0642db4cf43660cd9067f98721d146f876c5c'},
                                         callback=self.finish)
    
    def finish(self, response):
        pass


This is the spider I use to make posts. Maybe not the best way to do it, but I find the code easy to understand!
I share this today because I recently learned how to scrape with Selenium (it renders javascript!) and that's made me feel all excited
User avatar
Bicephalous Bob
Bicephalous Bob
Mafia Scum
User avatar
User avatar
Bicephalous Bob
Mafia Scum
Mafia Scum
Posts: 3828
Joined: June 4, 2013
Location: I don't know why you're linking me to pictures of babies on Facebook

Post Post #12 (ISO) » Sun Oct 30, 2016 2:47 am

Post by Bicephalous Bob »

You can't use the same form token twice, right?
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10559
Joined: April 28, 2011
Pronoun: he/they

Post Post #13 (ISO) » Sun Oct 30, 2016 11:05 am

Post by Psyche »

seems i can seems i can
User avatar
chamber
chamber
Cases are scummy
User avatar
User avatar
chamber
Cases are scummy
Cases are scummy
Posts: 10703
Joined: November 20, 2005

Post Post #14 (ISO) » Sun Oct 30, 2016 11:44 am

Post by chamber »

It's related to your session id. That wont work if it changes for some reason, and wouldn't work for someone else. With that said, by making it public someone else can probably authenticate as you now.
Taking a break from the site.
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10559
Joined: April 28, 2011
Pronoun: he/they

Post Post #15 (ISO) » Sun Oct 30, 2016 11:52 am

Post by Psyche »

interesting
User avatar
Annadog40
Annadog40
Owl of the Night Chat
User avatar
User avatar
Annadog40
Owl of the Night Chat
Owl of the Night Chat
Posts: 786
Joined: May 2, 2015
Location: Arendelle
Contact:

Post Post #16 (ISO) » Mon Mar 13, 2017 8:03 am

Post by Annadog40 »

So this is how you plan to make Donbot post?
This is my life now

Once you have 100 posts, click here to go to the page to join the speakeasy group.
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10559
Joined: April 28, 2011
Pronoun: he/they

Post Post #17 (ISO) » Mon Mar 13, 2017 8:55 am

Post by Psyche »

might switch to selenium
Post Reply

Return to “General Discussion”