【发布时间】:2022-01-07 15:28:22
【问题描述】:
我已经抓取了标题和网站链接,但我无法提取电话号码和地址。我怎样才能得到它们?
这是我所拥有的:
import re
import requests
from bs4 import BeautifulSoup
url='https://www.constructionplacements.com/top-construction-companies-in-india/'
req=requests.get(url)
soup =BeautifulSoup(req.content,'lxml')
for h4 in soup.find_all(lambda tag: tag.name=='h4' and re.search(r'^\d+\.',tag.text)):
title=h4.text
website=h4.find_next('a')['href']
【问题讨论】:
标签: python web-scraping beautifulsoup