如何使用python

时间:2019-05-18 08:12:40

标签: python python-3.x web-scraping

我正在尝试用python代码调用特定网站(例如:https://www.bloomberg.com/asia)的搜索栏。通过使用它,我想获得推荐的链接(如果在其中键入了任何内容)。

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

到目前为止,我已经尝试使用硒和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')

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

0 个答案:

没有答案