【发布时间】:2021-05-03 13:14:33
【问题描述】:
我正在尝试使用 Selenium 进行基本的谷歌搜索。这是非常基本的代码,但仍然没有返回任何搜索结果
!pip install kora -q
from kora.selenium import wd
import time
from bs4 import BeautifulSoup as BS
def get_results(search_string):
url = 'https://www.google.com/'
wd.get(url)
time.sleep(3)
subject_box = wd.find_element_by_css_selector('input[name=q]')
subject_box.send_keys('search_string')
subject_box.submit()
time.sleep(3)
html2 = wd.page_source
print(html2)
get_results('dog')
我的输出如下,我在任何地方都找不到搜索词 dog - 不止这些,但你明白了:
输出 1:
输出 2:
关于为什么会发生这种情况的任何建议?
【问题讨论】:
标签: python selenium google-chrome selenium-webdriver beautifulsoup