【发布时间】:2019-11-16 03:07:45
【问题描述】:
我正在尝试使用 beautifulsoup 从该站点中提取一些信息。我熟悉按类/属性提取标签,但是如何从“tr data-url”中提取 url?
import requests
import re
from bs4 import BeautifulSoup
url = "https://www.amcham.org.sg/events-list/?item%5Bdate_start%5D=07%2F05%2F2019&item%5Bdate_end%5D=09/17/2019#page-1"
webpage_response = requests.get(url)
webpage = webpage_response.content
soup = BeautifulSoup(webpage, "html.parser")
table = soup.find_all("tbody")
for i in table:
rows = i.find_all("tr")
for row in rows:
print(row)
<tr data-url="https://www.amcham.org.sg/event/8914">
<td class="date">July 09, 2019</td>
【问题讨论】:
标签: python-3.x