python请求无法获取整页 [英] python requests not getting full page

查看:73
本文介绍了python请求无法获取整页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

""这是我的密码""

import requests
from bs4 import BeautifulSoup
import random
from selenium import webdriver
url ="http://www.yopmail.com/en/?smith"
request = requests.get(url)
soup = BeautifulSoup(request.text, 'html5lib')
print(soup)

"它返回了此输出""

"""IT RETURNING THIS OUTPUT """

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
</head>
<body onload="document.getElementById('f').submit();">
<form action="." id="f" method="post">
<input id="yp" name="yp" type="hidden" value="XAQHlAwL5ZwL1ZQZlAGH3ZGV"/>
<input id="login" name="login" type="hidden" value="smith"/>
<input id="id" name="id" type="hidden" value=""/>
</form>
<noscript><br/><br/>  <strong>Your browser does not support javascript or it may be disabled</strong></noscript>

</body></html>

"我希望使用整个SRC代码代替""

""" I WANT WHOLE SRC CODE INSTEAD OF THIS"""

推荐答案

我宁愿将其写为评论而不是答案,因为我只是给您一个提示,但我的声誉不足写评论.这是我的两个美分:

I'd rather wanted to write this as a comment than an answer, as I'm only giving you a hint, but I don't have enough reputation to write comments. So here are my two cents:

注意行

<body onload="document.getElementById('f').submit();">
<form action="." id="f" method="post">

在您的HTML来源中.这可能是非常基本的保护措施,可以防止像您打算进行的抓取尝试那样进行操作,并且可以将 requests.get 的用法更改为 requests.post 即可;包括更改类似GET的参数

in that HTML source of yours. It might be a very basic protection against scraping attempts like you intend on doing, and it might be sufficient to change your usage of requests.get to requests.post instead; including changing GET-like parameter

/?史密斯

在网址中

改为POST参数.

in the URL to a POST parameter instead.

但是,同样好,之后您可能还会遇到更多代码,这需要您能够使用JavaScript.在这种情况下,请检查Basu_C的其他答案.

But just as well you might encounter even more code afterwards that requires you to be able to use JavaScript, though. Check the other answer by Basu_C in that case.

这篇关于python请求无法获取整页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆