是否可以使用python请求获取网页中的隐藏信息?srn=true)库?

2024-04-29 14:54:21 发布

您现在位置:Python中文网/ 问答频道 /正文

这是网址 “https://www.gumtree.com/p/sofas/dfs-couches.-two-3-seaters.-one-teal-and-one-green.-pink-storage-footrest.-less-than-2-years-old.-/1265932994

登录详细信息: 用户名:life@tech69.com 密码:湿婆@123你知道吗

当打开具有上述凭据的页面时,我们可以获得如下信息 联系方式 0770228XXXX号

但是如果添加?srn=true在url的末尾将给出以下信息 (https://www.gumtree.com/p/sofas/dfs-couches.-two-3-seaters.-one-teal-and-one-green.-pink-storage-footrest.-less-than-2-years-old.-/1265932994?srn=true

联系方式 07702287887号

我使用的代码如下:

import requests
from bs4 import BeautifulSoup
s = requests.session()
login_data = dict(email='life@tech69.com', password='shiva@123')
s.post('https://my.gumtree.com/login', data=login_data)
r = s.get('https://www.gumtree.com/p/sofas/dfs-couches.-two-3-seaters.-one-teal-and-one-green.-pink-storage-footrest.-less-than-2-years-old.-/1265932994?srn=true')
soup = BeautifulSoup(r.content, 'lxml')
y = soup.find('strong' , 'txt-large txt-emphasis form-row-label').text
print str(y)

但是上面的python代码仍然给出了部分信息 0770228XXXX号 如何使用python代码获取完整信息。你知道吗


Tags: andhttpscom信息wwwgreenonetwo
1条回答
网友
1楼 · 发布于 2024-04-29 14:54:21

该网站由recaptcha保护,这是一项专门设计用于防止自动登录的技术

所以线s.post('https://my.gumtree.com/login', data=login_data)

结果是

enter image description here

因此,当你试图转到其他网址你实际上没有登录,它不会透露号码。。。你知道吗

也许有办法绕过这一点,但我不确定任何即兴。。。你知道吗

相关问题 更多 >