2017-04-02 30 views
1

我有问题。我不知道如何发送POST数据和报废下一页的内容。 为了更好的理解简单的例子:曲线恢复发送POST数据输入形式和废页面,Python,请求库

的Facebook网站,一个输入:http://m.facebook.com/login/identify?ctx=recover
输入:

<input autocapitalize="off" class="y z ba" id="login_identify_search_placeholder" name="email" autofocus="1" placeholder="Adres e-mail lub numer telefonu" type="text">

我要让脚本,恢复我的帐户,所以我想送我的通过邮件输入邮件并报废下一页。我的代码:

import requests 
from BeautifulSoup import BeautifulSoup 
Soup = BeautifulSoup 
headers = {'User-Agent': 'Mozilla/5.0'} 
payload={ 
"lsd": "AVqS_aom", 
"email": "mycorrect email", 
"did_submit": "Search" 
} 

session = requests.Session() 
x = session.post('http://m.facebook.com/login/identify?ctx=recover', headers=headers, data=payload) 
#print x.content 
x.encoding = "utf-8" 
parsed = BeautifulSoup(x.content) 
print(parsed) #It's print me only started page, not next page with my finded profile. WTF?? 

回答

0

如果响应是另外一个页面,我会建议使用像BeautifulSoup,从中解析HTML和提取数据,并且如果你还需要历史,你有它x.history,取决于哪您使用Python版本中,可以使用像BeautifulSoup: 蟒3.X:parsed = BeautifulSoup(x.content.decode("utf-8"), "html.parser") 蟒2.x的:parsed = BeautifulSoup(x.content, "html.parser")

+0

类型错误: '模块' 对象不在行调用的:解析= BeautifulSoup(x.content, “html.parser”) – PythonLearn

+0

你应该首先安装BeautifulSoup,使用pip,'pip install bs4',然后在Python中从bs4 im港口BeautifulSoup' – StetHD

+0

男人,我已经安装了BeautifulSoup和进口。必须添加:从BeautifulSoup导入BeautifulSoup汤= BeautifulSoup现在它的工作,但打印我只有起始页,而不是下一页发送POST数据....看看我的代码,它的更新 – PythonLearn