使用Python 3.5 Requests库在论坛上发布

时间:2016-01-21 22:57:50

标签: python web-crawler python-requests

我一直在尝试使用带有请求库的Python 3.5在特定论坛中发布主题。

问题是,当我查看实际将消息发布到论坛的帖子请求中的表单数据时,我看到了很多数据。不知道从哪里获取它以便使用Python

传递请求

我的代码如下

import requests

with requests.Session() as c:

    urlpost = "http://forum.outerspace.com.br/index.php?threads/t%C3%B3pico-oficial-heroes-of-the-storm.355675/add-reply"

    c.get(urlpost)
    cks = c.cookies
    headers={}
    headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"
    headers["Referer"] = "http://forum.outerspace.com.br/index.php"
    mypost = dict(message_htlm="<p>hi</p>",_xfRelativeResolver="http://forum.outerspace.com.br/index.php?threads/t%C3%B3pico-oficial-heroes-of-the-storm.355675/")
    c.post(urlpostt,headers=headers, cookies=cks, data=mypost)

发布消息时请求传递的数据是:

message_html: 'My Message'
_xfRelativeResolver: 'this is the referer'
attachment_hash:7ef8a3ea0dff5cc4fbaa32b8dd702d1f: #not sure where it came from
last_date:1448677064 #not sure where it came from
last_known_date:1448677064 #not sure where it came from 
_xfToken:224338,1453416035,1bddacdfc5e0040f5b288f1a8e6e6cbfcad78200 #not sure where it came from
_xfRequestUri:/index.php?threads/como-comprar-sem-dificuldades-jogos-assinaturas-etc-para-xbox.435327/
_xfNoRedirect:1
_xfToken:224338,1453416035,1bddacdfc5e0040f5b288f1a8e6e6cbfcad78200 #not sure where it came from
_xfResponseType:json

虽然如何获得所有这些值?

0 个答案:

没有答案
相关问题