beauthulsoup不会使用selenium获取页面源代码

2024-10-03 02:35:29 发布

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

我正在尝试抓取一个网页,但我无法使用selenium获取网站的html文本。在

这是我目前为止的代码

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from bs4 import BeautifulSoup
import urlparse

search_term = raw_input("What is your search term?: ")
url = "https://www.google.co.uk/search?client=ubuntu&channel=fs&q="
googurl = url+search_term
driver = webdriver.Firefox()

htmltext = driver.get(googurl)
soup = BeautifulSoup(htmltext.page_source)

回溯一下

^{pr2}$

Tags: fromimporturl网页supportsearch网站driver