【发布时间】:2022-07-06 02:22:37
【问题描述】:
我需要从 https://www.comicshoplocator.com/StoreLocator 解析商店名称 (<div class="LocationName">)。
问题是——当您在搜索中输入邮政编码(例如 73533)时,它不会出现在 URL 中。
因为那个 python 看不到页面上的元素。
这是我的代码 sn-p。因此,我没有收到任何输出。
如何让 python 看到带有邮政编码的输入? 谢谢
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
browser = webdriver.Firefox(executable_path=r'C:\Geckodriver\Geckodriver.exe')
browser.get('https://www.comicshoplocator.com/StoreLocator')
browser.find_element(By.NAME, 'query').send_keys('73533' + Keys.RETURN)
html = browser.page_source
soup = BeautifulSoup(html, features="html.parser")
for tag in soup.find_all('div', class_="LocationName"):
print(tag.text)
【问题讨论】:
标签: python selenium parsing url beautifulsoup