python 中的评论者 3

Comment maker in python 3

我想制作一个简单的脚本来在此页面中创建评论: http://pountex.altervista.org/risolvere-bug-apt-get/

我尝试过请求:

import requests

url = "http://pountex.altervista.org/wp-comments-post.php"

payload = { "comment":"a",
            "author":"a a",
            "email":"a@a.com",
            "url":"a.com",
            "submit":"Commento all'articolo",
            "comment_post_ID":"178",
            "comment_parent":"0",
            }

r = requests.get(url, params=payload)

并通过发出 http 请求:

import socket

url = "http://pountex.altervista.org/wp-comments-post.php"

request = open("request.txt").read()

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("pountex.altervista.org", 80))
s.send (str.encode(request))

您可以在此处找到 request.txt:http://pastebin.com/iWYRk7rk

对该页面发表评论有何建议?

感谢您的帮助。

我通过制作这个脚本解决了这个问题:

from robobrowser import RoboBrowser

browser = RoboBrowser()
url = "http://pountex.altervista.org/risolvere-bug-apt-get/"
browser.open(url)
form = browser.get_form(id="commentform")
form["comment"] = "a"
form["author"] = "a a"
form["email"] = "a@a.com"
form["url"] = "a.com"
browser.submit_form(form)