爬虫时候所用、
目标:获取标签"新闻发布“所对应的href标签,如下图中标红的地方的标签
import requests
from bs4 import BeautifulSoup
import re
#本段是获取中国商务部俄罗斯的新闻
web_url = 'http://www.mofcom.gov.cn/'
# Send a GET request to the URL and store the response
response = requests.get(web_url)
soup = BeautifulSoup(response.content, 'html.parser')
# Find the 'a' tag that contains certain text
tag = soup.find_all('a',text = '新闻发布')
print(tag)
最后得到了如下结果: