如何使用python从搜索栏建议中获取网页链接

2024-04-20 09:37:45 发布

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

我试图在python代码中调用特定网站的搜索栏(例如:https://www.bloomberg.com/asia)。通过使用它,我想得到推荐的链接,如果有什么是在它键入的

或者我们可以直接在python代码中使用网站的搜索栏功能

到目前为止,我已经尝试使用selenium和beautifulsoup库从url获取描述,但每次都必须手动更改url

browser = webdriver.Chrome(executable_path=r"C:/chromedriver.exe")
# above is my path to chromedriver, replace it with your own.
browser.maximize_window()
browser.get('https://www.bloomberg.com/quote/RIL:IN')
time.sleep(5) # wait 5 seconds for the page to load the js
pageSource = browser.page_source
soup = BeautifulSoup(pageSource, 'html.parser')
Description = soup.find_all(class_='left__3cc58f98 
description__bff5f1e8')

我希望输出的网址推荐在搜索栏或功能的搜索栏在我的代码如果可能的话


Tags: thetopath代码https功能browsercom