用Python请求单击按钮

2024-09-29 17:14:09 发布

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

我会单击带有requests库的按钮。我知道这是不可能的,但我已经尝试用Python执行该函数。因此: 这是HTML按钮代码:

<a href="#" style="color:blue; font-size:32px; font-weight:bold;display:inline-block;" onclick="closeOverlay()">Continue to your image</a>

这是功能代码:

function closeOverlay(){
    //hide chaturbate
    setCookie("overlay","true",1,"/","imagetwist.com");
    document.getElementById("rang2").style.display = "none";
    $('#rang2').children('iframe').remove();
}

这是我的Python代码:

import requests
import time
from bs4 import BeautifulSoup
proxies={"http":"http://3.84.27.209:8080"}
url="https://imagetwist.com/99rhhpzjx6bq/server-iconns.png"
page=requests.get(url,proxies=proxies)
requestsJar=requests.cookies.RequestsCookieJar()
requestsJar.set("overlay","true",path="/",domain="imagetwist.com")
page=requests.get("https://imagetwist.com/99rhhpzjx6bq/server-iconns.png#",proxies=proxies,cookies=requestsJar)
print(page.text)

但它不起作用,缺少什么?我意识到它不起作用,因为视图没有增加(我试图绕过检查) 对不起,我的英语不好


Tags: 代码importcomtruestyledisplaypagerequests
2条回答

我建议做一些更简单的事情。不要只关注请求和代理内容

您不能用请求库模拟点击,请使用selenium。最好是在无头模式下

相关问题 更多 >

    热门问题