from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as uReq
import pandas as pd
sca_url = "https://steakcookoffs.com/cookoffs?EventViewMode=1&EventListViewMode=1"
client = uReq(sca_url)
page_html = client.read()
page_soup = soup(page_html, features='lxml')
sca_reg_links_tags = page_soup.select(".inner a")
print(sca_reg_links_tags)我怎么才能得到注册链接??我也尝试过使用sca_reg_links_tags = page_soup.find('div',{“class”:“内部”}),但是它会得到同样的东西。
发布于 2022-07-26 22:28:45
尝试:
soup.find_all("a", string="Register")另外,bs4文档:
发布于 2022-07-26 22:31:05
尝试如下:
sca_reg_links_tags = page_soup.find_all('a', {'title': 'View event details'})
lst = []
for link in sca_reg_links_tags:
lst.append(link['href']+'/Registration')
lst[:5]
['https://steakcookoffs.com/event-4572070/Registration',
'https://steakcookoffs.com/event-4572070/Registration',
'https://steakcookoffs.com/event-4692176/Registration',
'https://steakcookoffs.com/event-4692176/Registration',
'https://steakcookoffs.com/event-4901583/Registration']烹饪快乐!
https://stackoverflow.com/questions/73130260
复制相似问题