【发布时间】:2019-01-16 06:34:22
【问题描述】:
<div class="product-grid-item ">
<meta itemprop="url" content="https://undefeated.com/products/air-humara-
17-qs-silver-carotene-bluespark-black">
上面的代码是我要搜索的,“humara”这个词就在那里。
from Utilities import custom_logger as cl
from Base.basepage import BasePage
import logging
from bs4 import BeautifulSoup
class NewShoePage(BasePage):
log = cl.customLogger(logging.DEBUG)
def __init__(self, driver):
super().__init__(driver)
self.driver = driver
def searchForKeywords(self, keywords):
html = self.driver.page_source
soup = BeautifulSoup(html, 'html.parser')
keywordsFound = soup.find_all('meta', content=keywords)
print(keywordsFound)
当我打电话时:
searchForKeywords('humara')
它什么也没打印出来
我想在网页的元内容标签中找到“humara”这个词,但它什么也没返回。完成后,我想重定向到该链接。
【问题讨论】:
-
在不知道您尝试从哪个页面获取此数据的情况下,我们无法为您提供帮助。它可能是一些简单的东西,比如大写(
Nike而不是nike),因为这些东西是区分大小写的。
标签: python html selenium selenium-webdriver beautifulsoup