Python要求接受条款和条件

时间:2017-04-02 07:29:49

标签: python python-3.x python-requests

我正在尝试访问某个网站,但我无法接受条款和条件来提出我想要的请求。

这是我的代码,

import cfscrape
site = "https://tr.0day.today/search"
kw = input("Search: ")
class zero_day:
    def ara(self):
        with cfscrape.create_scraper() as s:
            payloads = {
                "search_requests":kw}
            r = s.get(site)
            r = s.post(site, data=payloads)
            print(r.text)

zero_day = zero_day()
zero_day.ara()

当我运行此脚本时,它会返回&#34的页面;您是否接受条款和条件"。如何访问我想要的页面?

1 个答案:

答案 0 :(得分:0)

这是一个例子:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get('https://planning.ashford.gov.uk/buildingControl/Default.aspx?new=true')
agree = driver.find_element_by_id("CPH_Details_Agree_CheckBox")
submit = driver.find_element_by_id("CPH_Details_Submit_Button")
agree.click()
submit.click()

您可以在更多工具 -> 开发者工具中找到对协议框的引用,然后搜索类似的内容。