python post 表单类数据_以输入表单和剪贴簿页面,Python,请求库发送POST数据

I have problem. I dont know how i can send POST data and scrap content of next page.

Simple Example for better understanding:

Facebook website of profile recovery with one input: http://m.facebook.com/login/identify?ctx=recover

Input:

I wanna make script, which recover my account, so i wanna send my email to input by POST and scrap next page. My code:

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??

解决方案

If the response is another page, I would recommend to use something like BeautifulSoup, to parse html and extract data from it, and also if you need history, you have it x.history, depends on which version of python you are using, you can use BeautifulSoup like:

python 3.x: parsed = BeautifulSoup(x.content.decode("utf-8"), "html.parser")

python 2.x: parsed = BeautifulSoup(x.content, "html.parser")

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值