how to make python make a post
- Psyche
-
Psyche he/theySurvivor
- Psyche
he/they- Survivor
- Survivor
- Posts: 10559
- Joined: April 28, 2011
- Pronoun: he/they
how to make python make a post
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??- Psyche
-
Psyche he/theySurvivor
- Psyche
he/they- Survivor
- Survivor
- Posts: 10559
- Joined: April 28, 2011
- Pronoun: he/they
updated problem description: http://stackoverflow.com/questions/4009 ... ormrequest
api for formrequest (ctrl+f formrequest!): https://doc.scrapy.org/en/latest/topics ... ponse.html- Bicephalous Bob
-
Bicephalous Bob Mafia Scum
- 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
- Psyche
-
Psyche he/theySurvivor
- Psyche
- inte
-
inte Mafia Scum
- inte
- vonflare
-
vonflare doot
- vonflare
- doot
- doot
- Posts: 3093
- Joined: January 1, 2014
- Location: Blue Gatorade Factory
- chamber
-
chamber Cases are scummy
- chamber
- Cases are scummy
- Cases are scummy
- Posts: 10703
- Joined: November 20, 2005
- Claus
-
Claus Mafia Scum
- Claus
- Mafia Scum
- Mafia Scum
- Posts: 1734
- Joined: June 1, 2007
- Location: Tsukuba
- Contact:
- Flubbernugget
-
Flubbernugget Survivor
- Flubbernugget
- Bicephalous Bob
-
Bicephalous Bob Mafia Scum
- 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
Replication crisis hit you too huhPsyche, 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.- Psyche
-
Psyche he/theySurvivor
- Psyche
- Psyche
-
Psyche he/theySurvivor
- Psyche
he/they- Survivor
- Survivor
- Posts: 10559
- Joined: April 28, 2011
- Pronoun: he/they
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- Bicephalous Bob
-
Bicephalous Bob Mafia Scum
- 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
- Psyche
-
Psyche he/theySurvivor
- Psyche
he/they- Survivor
- Survivor
- Posts: 10559
- Joined: April 28, 2011
- Pronoun: he/they
- chamber
-
chamber Cases are scummy
- chamber
- Cases are scummy
- Cases are scummy
- Posts: 10703
- Joined: November 20, 2005
- Psyche
-
Psyche he/theySurvivor
- Psyche
- Annadog40
-
Annadog40 Owl of the Night Chat
- Annadog40
- Owl of the Night Chat
- Owl of the Night Chat
- Posts: 786
- Joined: May 2, 2015
- Location: Arendelle
- Contact:
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.Copyright © MafiaScum. All rights reserved.
- Annadog40
- chamber
- Psyche
- Bicephalous Bob
- Psyche
- Bicephalous Bob
- Claus
- chamber
- vonflare
- Bicephalous Bob
- Psyche
- Psyche