Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x BeautifulSoup返回None_Python 3.x_Selenium_Beautifulsoup - Fatal编程技术网

Python 3.x BeautifulSoup返回None

Python 3.x BeautifulSoup返回None,python-3.x,selenium,beautifulsoup,Python 3.x,Selenium,Beautifulsoup,为什么页面返回为无? 这里是错误 from selenium import webdriver from bs4 import BeautifulSoup import time ################import the chrome web driver and define the location############### driver = webdriver.Chrome(executable_path='C:/Users/../Downloads/cd79/chrome

为什么
页面
返回为
? 这里是错误

from selenium import webdriver
from bs4 import BeautifulSoup
import time
################import the chrome web driver and define the location###############
driver = webdriver.Chrome(executable_path='C:/Users/../Downloads/cd79/chromedriver.exe')
###################################################################################

###########open the web page and print the title##############
page = driver.get("https://kjustin765.wixsite.com/website")
print(driver.title)
driver.maximize_window()
time.sleep(5)
while True:
    soup = BeautifulSoup(page.content, 'html.parser')
    button1 = soup.find('span', class_='pWNha').text
    if 'Yes' in button1:
        driver.refresh()
    else:
        button1.click()

要获取正确的数据,请使用
page.page\u source
而不是
page.content

soup = BeautifulSoup(page.content, 'html.parser')
AttributeError: 'NoneType' object has no attribute 'content

如果您使用
.content
方法请求页面,则该方法来自
请求
库。例如:

soup = BeautifulSoup(page.page_source, 'html.parser')
美化组(driver.page_源代码'html.parser')
import requests
page = requests.get(my_url).content