【发布时间】:2022-01-21 22:57:42
【问题描述】:
我想从本网站的日历中提取所有活动的链接,然后抓取每个活动的信息。
这是网址: https://thalheim.ch/index.php/aktuell/veranstaltungen
这是我写的代码:
from bs4 import BeautifulSoup
import requests
def get_website_news_links_thalheimCh():
url = 'https://thalheim.ch/index.php/aktuell/veranstaltungen'
response = requests.get(url, allow_redirects=True)
print("Response for", url, response)
soup = BeautifulSoup(response.content, 'html.parser')
all_links = soup.select('table tbody tr div.fc-daygrid-day-events a')
print(all_links)
result = get_website_news_links_thalheimCh()
对于all_links 变量,我总是得到 []。
我想我做错了什么。
\我查看了在“网络”选项卡上找到的链接,但找不到任何可以帮助我的链接。
【问题讨论】:
-
注意 首先,总是看看你的汤——这就是真相。内容总是与开发工具中的视图略有不同。 内容是动态提供的,因此可以使用 api 或 selenium 来获取结果。
标签: python web-scraping beautifulsoup